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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote execution of a script on a HMC

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
How do i execute a custom script remotely on a HMC using SSH?

I have set up a trusted ssh key exchange between HMC and client LPAR which works. For example, the below works:
remote mach> ssh -l hscroot 192.167.12.11 uname -a

When i attemp to run a script:
remote mach> ssh -l hscroot 192.167.12.11 ./scriptname

it complains about the use of "/" in the restricted shell.
How do i get round this to execute the custom script?
 
Have you tried this:
remote mach> ssh -l hscroot 192.167.12.11 scriptname

In any case, you shouldn't be writing/customizing and saving scripts on an HMC.

I write the script logic on the remote machine, and ssh into the HMC to run the HMC CLI commands whenever necessary.

HTH,

p5wizard
 
This is what i am doing - executing a script from the client LPAR to the HMC.

The script cycles through a list of frames and executes

while read FRAME
do
ssh -l hscroot 192.168.xxx.xxx lshwinfo -r sys -e $FRAME
done<frame.list

Any ideas on implementing this?
 
What is wrong with how you stated it?

The file frame.list is a file on the LPAR, right?
Then, for every line in the file (frame name) you ssh in to the HMC to run the lshwinfo command. Should work.

What is your output like?

other loop method:

for FRAME in $(<frame.list)
do
ssh hscroot@192.168.xxx.xxx lshwinfo -r sys -e $FRAME
done


HTH,

p5wizard
 
I just got this script while googling!

I hope you find it useful for your case:

Code:
Here is a script to generate the list of slots of all managed systems on a particular IBM HMC used to manage logical partitions (LPARs).

#!/bin/shPATH=/opt/IBMJava2-131/jre/bin:/opt/hsc/bin:/opt/csm/bin:/home/hscroot/binexport PATHquery_cecs | awk '{if ( NR != "1" && NR != "2" ) {         printf("\nManaged System: %s\n",$1);        system("lshwres -m " $1 " -r slot");        printf("\n");}}'

To run this command from a remote server, as the same user on the hmc (usually hscroot):

# ssh hmc ./show_slots.sh 

Or, if the current directory is in your PATH:

# ssh hmc show_slots.sh 

Note: If you setup passwordless ssh, you can run this script without entering a password.

Regards,
Khalid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top