Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

is it possible to define a list of "Items" within a script and advise the script to perform a specified action for each of these items ?

How can I do it ?

Thanks in advance !

Regards
Thomas
 
Can you expand a little, an example of what you've in mind would help.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
I'd like to write a script that performs an lsvg command (using tail, int, etc.) to determine the amount of free PP's for each volume group on certain machines.

In the past I would have created a separate file containing the List of machines (e.g. IP adresses) and then performed an lsvg for each line / item in the file using "cat", etc.

Now I'd like to include the IP list in the script itself so that i don't need this separate file anymore. Is this possible ?

Regards
Thomas
 
Could you please paste the script you had to understand the question clearly?

Were you using ssh?
 
An example of what you had in mind would help us but if I'm understanding this correctly, this might work:

Code:
for IP in 192.168.0.10 192.168.0.11 192....
 do
        ssh ${IP} "lsvg rootvg | awk '/FREE PPs:/{gsub(/\(|\)/,\"\");print \$6}"
 done

This example is using ssh but you can use whatever tool your using to run this on the remote system.

Regards,
Chuck
 
Hi,

that's exactly what I needed !

Thanks a lot ...

But now there's another problem:

I'd like to run 2 ssh commands on each machine. The first is supposed to read the value for FREE PP's from lsvg and put that into a variable. The second is supposed to read the PP size value from lsvg and put that into another variable.

After that I'd like to calculate with these two variables and perform certain actions for a few cases, but after the end of the awk command all variables I set
(e.g. free = $6 ) are empty and I can't find a way to export them ...

Could you help me with that too ?

Regards
Thomas
 
use perl for scripting , put the result of your commands in an array,then you can get all the data you want from it.


rgds,

R.
 
You could use perl but you can still get the same result from tweaking the above code:

Code:
for IP in 192.168.0.10 192.168.0.11 192....
  do
      ssh ${IP} "lsvg rootvg | awk '/FREE PPs:|PP SIZE/{gsub(/\(|\)/,\"\");printf \"%s \", \$6}'" | read PPSIZE PPFREE
  
  # Example of getting total free space with above values
  ((TOTAL=PPSIZE*PPFREE))
  echo "${TOTAL} MB FREE"
  done

Regards,
Chuck
 
Hoi,

now THAT'S quite a command ;-)

Thanks a lot, that's exactly the output I need !
 
Nice script cspilman,

TSch, this same thing could be done by using dsh!

just look for this if you want an alternative.

regards,
Khalid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top