HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need ability to run remote shell script, capture r...
Operating System - HP-UX
1827852
Members
1622
Online
109969
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2002 12:49 PM
03-21-2002 12:49 PM
I have the need for running a interactively remote shell script on a remote server and perform further processing on the local host in a loop.
Does anyone have such a critter.
I've tried a do while ... read filename done and it terminates after the first remsh executes.
I've also tried for n in VARIABLE_LIST ... and still can't capture the results and do further processing.
Script does the following:
Read a configuration file.
For the first argument in each row, do the following:
1 - execute remsh command
2 - Capture output from remote shell command.
3 - Depending on the results, send a file back to the local host.
4 - Do processing on the local host on the file created by the remote host.
5 - Process the nex entry from the configuration file.
Once all entries are processed, exit the loop.
I can't capture the exit code from the script executed by the remote shell. When I attempt to loop via the read command, the eof gets set after the first remsh execution even if there are more rows.
Any ideas will be appreciated.
Thanks... jack...
Does anyone have such a critter.
I've tried a do while ... read filename done and it terminates after the first remsh executes.
I've also tried for n in VARIABLE_LIST ... and still can't capture the results and do further processing.
Script does the following:
Read a configuration file.
For the first argument in each row, do the following:
1 - execute remsh command
2 - Capture output from remote shell command.
3 - Depending on the results, send a file back to the local host.
4 - Do processing on the local host on the file created by the remote host.
5 - Process the nex entry from the configuration file.
Once all entries are processed, exit the loop.
I can't capture the exit code from the script executed by the remote shell. When I attempt to loop via the read command, the eof gets set after the first remsh execution even if there are more rows.
Any ideas will be appreciated.
Thanks... jack...
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2002 01:06 PM
03-21-2002 01:06 PM
Solution
Hi Jack:
That question has come up many times. I will simply duplicate one of my earlier posts.
NOTE: This is the most general solution to the problem when you also need STDOUT and STDERR from your remsh'ed process. i.e. This method works in all cases.
The remsh exit code of 0 only means that the script was able to be launched. The exit status of the remote command is not returned. There is a workaround I have used for a long time.
REM_ERR_FILE=/var/tmp/x${$}.err
remsh remote_host my_command $REM_ERR_FILE
LOCAL_STAT=$?
$LOCAL_STAT only tells us about the success of remsh itself
Now my_command on the remote host can get the
value of $REM_ERR_FILE; any status values you are interested in can be written to that file by your script on the remote host.
When the remsh command finishes you can then
REM_STAT=`remsh remote_host cat ${REM_ERR_FILE}`
to capture the remote commands status. (You should then issue a final remsh to remove the $REM_ERR_FILE.)
It's a little complicated but it does work. Since we generate a process id dependent filename on the local host, you don't have to worry about filename collision when multiple instances are running. This method also leaves stderr and stdout for their normal use.
You can serach the Forums for remsh and status for other methods.
Regards, Clay
That question has come up many times. I will simply duplicate one of my earlier posts.
NOTE: This is the most general solution to the problem when you also need STDOUT and STDERR from your remsh'ed process. i.e. This method works in all cases.
The remsh exit code of 0 only means that the script was able to be launched. The exit status of the remote command is not returned. There is a workaround I have used for a long time.
REM_ERR_FILE=/var/tmp/x${$}.err
remsh remote_host my_command $REM_ERR_FILE
LOCAL_STAT=$?
$LOCAL_STAT only tells us about the success of remsh itself
Now my_command on the remote host can get the
value of $REM_ERR_FILE; any status values you are interested in can be written to that file by your script on the remote host.
When the remsh command finishes you can then
REM_STAT=`remsh remote_host cat ${REM_ERR_FILE}`
to capture the remote commands status. (You should then issue a final remsh to remove the $REM_ERR_FILE.)
It's a little complicated but it does work. Since we generate a process id dependent filename on the local host, you don't have to worry about filename collision when multiple instances are running. This method also leaves stderr and stdout for their normal use.
You can serach the Forums for remsh and status for other methods.
Regards, Clay
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2002 01:25 PM
03-21-2002 01:25 PM
Re: Need ability to run remote shell script, capture results and act on results as they are returned.
This is tricky, but I've done it. Here is one secret. Be sure to use quotation marks around your command:
remsh HOST "command">>OUTFILE.out 2>/dev/null
This writes the standard output from the remote hose to a file on the local host (outfile.out). Next process the output file, and remsh the remote system to take action on it.
It'll take a few tries to get it right. I use this methodology to run bdf on multiple systems, and then assemble the data into a spreadsheet for trending/planning purposes.
Chris
remsh HOST "command">>OUTFILE.out 2>/dev/null
This writes the standard output from the remote hose to a file on the local host (outfile.out). Next process the output file, and remsh the remote system to take action on it.
It'll take a few tries to get it right. I use this methodology to run bdf on multiple systems, and then assemble the data into a spreadsheet for trending/planning purposes.
Chris
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP