rsh help - getting the output of remote script to local server.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rsh help - getting the output of remote script to local server.
# 1  
Old 02-25-2009
rsh help - getting the output of remote script to local server.

Hi,

I have a script that runs for an hour.
Have to run it on remote server and need the output it produces on the remote server to decide for failure or success.
I run it through a Autosys Job which logs the outputs, both 1 & 2.
I use the commands
1) rsh <SERVER> 'nohup /tmp/xyz.ksh &'
2) rsh <SERVER> 'nohup /tmp/xyz.ksh >/tmp/ark.out 2>&1 &'

command 1 solves my purpose, but it holds up the port. So if the script runs for 3 hours, the port will be in use for 3 hours which is not desirable.

command 2 releases the port, but produces output on the remote server. So my Job doesn't know if the script was success or failure on the remote server.

One way could be to get the output file rsh'd to the host server again and do the processing.
I wanted to know if there is some functionality, to release the port used and also get the success or failure of the remotely executed script.

Thanks
# 2  
Old 03-05-2009
I suppose you are referring to https://www.unix.com/shell-programmin...-commands.html. I don't mind at all that you ignored my advice concerning nohup, but my advice would have been different in any case had I known the more ultimate goal.

Anyway, this line "the port will be in use for 3 hours which is not desirable" makes no sense at all. There is no port held up in such a case.

In this case, you need to run rsh so that the entire job on the remote server runs in the foreground. You then background the rsh process, but not until after checking the exit code:
Code:
rsh <SERVER> 'nohup /tmp/xyz.ksh 2>&1'  >output.job1 || echo job1 failed  &

# 3  
Old 03-06-2009
With this command...
"rsh <SERVER> 'nohup /tmp/xyz.ksh &'"
the rsh will wait till the output on the script "/tmp/xyz.ksh" is generated..
so if this script takes 3 hours....the rsh will wait for 3 hours to complete, i.e. the output of the script "/tmp/xyz.ksh" which is executed on the remote server will be written to the host server.
During this time, the rsh is still active and creating problem since there is a connection between the 2 servers...and this i feel uses a port.
I may be wrong as i'm not that deep into unix.....

I have the problem solved temporarily wherein i have put a condition to check the "err" file produced remotely and have the Autosys Job fail if it finds the "err" file with some stuff populated in it.
But still want to know the solution if any for the porblem i posted.
# 4  
Old 03-06-2009
Quote:
During this time, the rsh is still active and creating problem since there is a connection between the 2 servers...and this i feel uses a port.
True, a port is used, but there are over 30,000 such ports available to programs. It is in reality, nothing to worry about.

It's best to do it like this
Code:
rsh <SERVER> /tmp/xyz.ksh  >locally-saved-report.out   &
wait

# 5  
Old 03-06-2009
In our environment...
the SA has reduced the no of ports....thats where the problem arises...
Also i don't have just one job...
There are 2 jobs each of the total of 90 servers.
Each Job has within it some 5 "rsh's"..so in all somewhere around 1000 "rsh's". There are many more applications running out here on these servers.
Me blocking so many ports is a bad thing for others, so wanted to reduce as much as I can.
As I said I do have a temporary solution where I create the o/p on the remote server, and check it later, but need to know if there is any other way to get it after the remote run directly.
# 6  
Old 03-07-2009
Look into a job queuing system like SGE or Torque. While these are meant for compute clusters, it makes sense to configure and install in your case. You simply submit jobs to the queue, which determines an appropriate cluster host to run on (you can also specify certain jobs to certain hosts, if needed), and when the job is done, you get an email with (optionally) the output of the command. Only a few ports are needed per machine, and it is a lot cleaner than RSH. I found SGE to be cleaner than Torgue. Both are free and open-source.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep remote multiple hosts output to local server

Hello all, i'm trying to create a report by greping a pattern on multiple remote hosts and creta a simple report, actually i did this, is ther any better way to do this. #!/bin/bash for host in `cat RemoteHosts` do ssh $host -C 'hostname 2>&1; grep ERROR /var/log/WebServer.log.2019-09-21... (0 Replies)
Discussion started by: charli1
0 Replies

2. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

3. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

4. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

5. Shell Programming and Scripting

Execute a local script against a remote server

I am unable to run the below script against a remote server due to syntax error (then unexpected), but i am able to run it locally. Am i executing it correctly or is there any other way to execute it. ssh username@servernname ksh -s < scriptname #!/bin/ksh function record { ((end =... (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies

6. Shell Programming and Scripting

Executing local script/command on remote server

I have a command that I want to run on machine B from machine A. If I run the command on machine B locally, it works fine. Here is the command: for n in `find /data1/ -name 'ini*.ext'` ; do echo cp $n "`dirname $n `/` basename $n .ext`"; done From machine A, I issue this command ... (3 Replies)
Discussion started by: dirtyd0ggy
3 Replies

7. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

8. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies

9. UNIX for Advanced & Expert Users

rsh not finding .profie in the remote server; please help

while using the rsh command to execute script S1 in the remote server it is not using the .profile in remote server. The script S1 which is using sqlplus is not able to set up the ORACLE environment which is defined in .profile Thanks in advance.... (3 Replies)
Discussion started by: jaiankur
3 Replies

10. Shell Programming and Scripting

executing a remote location script from local server

hi i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script i want to run a shell script(remote location) from my local server i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies
Login or Register to Ask a Question