rsh problem

Hi,

I am using rsh command in scripting. But I wan to run the script as a bg process.

When I run the script, it says stopped.

My doubt is ....if I use the rsh in scripting ......bg is possible or not ???

EX: test-rsh

rsh 172.16.73.38 df -k >DF.log

Result when I run this script

root@FRAPRB2BADE1 # nohup ksh test-rsh &
Sending output to nohup.out
[1] 24994
root@FRAPRB2BADE1 #

[1]+ Stopped nohup ksh test-rsh
root@FRAPRB2BADE1 #

The process will not run as bg??

Waiting for your replay

------
vastare

Hi,

no one is there to answer for this question ??????? :confused:

its very urgent.....please help me out. :mad:

------------
vastare

first off --- forum rules says you're not suppose to bump up questions so you broke this rule by putting in your second post on this thread ...

second, your test-rsh is not accurate because the "df -k" command you are giving terminates immediately after it gives you a one-time output ... try testing with a "ls -l /dir/file" loop instead ... if your result still disallows you putting the rsh job in the background, try the code below ...

run the rsh command in the background inside a sub-shell ...

(rsh servername "jobname" < /dev/null > /dir/file 2>&1 &)

Hello,

Sorry for the second post on this thread ...

I explained every steps here

  1. script
    root@FRAPRB2BADE1 # cat test-rsh
    #!/usr/bin/ksh

rsh 172.16.73.38 ls -l 2>>test.log

  1. run the script as background processes
    root@FRAPRB2BADE1 # nohup ksh test-rsh &
    Sending output to nohup.out
    [1] 6476
    root@FRAPRB2BADE1 #

[1]+ Stopped nohup ksh test-rsh

  1. grep the process
    root@FRAPRB2BADE1 # ps -ef | grep test-rsh
    root 6476 6431 0 17:37:50 pts/2 0:00 ksh test-rsh

  2. type exit
    root@FRAPRB2BADE1 # exit
    exit
    There are stopped jobs.

  3. grep the process
    root@FRAPRB2BADE1 # ps -ef | grep test-rsh
    root 6476 6431 0 17:37:50 pts/2 0:00 ksh test-rsh

root@FRAPRB2BADE1 # exit
exit
There are stopped jobs.

  1. grep the process
    root@FRAPRB2BADE1 # ps -ef | grep test-rsh
    root 6476 6431 0 17:37:50 pts/2 0:00 ksh test-rsh

root@FRAPRB2BADE1 # exit
exit

  1. grep the process
    root@FRAPRB2BADE1 # ps -ef | grep test-rsh
    root@FRAPRB2BADE1 #

When i grep the process in the last statement....nothing is showing??

I want to know the root cause for this...

Please help me ..... It's very interesting to know the reason

-------------
vastare

your test is still terminating after the lone "ls -l" call ... you need to create a script that runs a command loop (see below) and then copy that over to the remote server and then test with that ...

while true
do
    ls -l /dir/file
done

Hi,

Thank you, very much....

The rsh problem is solved.

If you want to run the rsh in a bcakground, use -n option with the rsh command.

Here is the proper syntax to use the rsh (remote shell) command without having the remote shell remain active until the remote command is completed.

rsh -n machine  'command &gt;&/dev/null &lt;/dev/null &'

Where machine is the name of the remote computer and command is the remote command to be performed.
This works because the -n flag attaches the rsh's standard input to /dev/null so you can execute the complete rsh command in the background of the local computer. Also, the input/output redirections on the remote computer (the stuff inside the single quotes) makes rsh think the session can be terminated since there is no data flow. In all truth, you don't have to use /dev/null. Any filename will work.

:slight_smile: :slight_smile: :slight_smile: :slight_smile:

Ex:

while true
do

\#rsh -n remote-IP command &gt;&gt;logfile 
  rsh -n 172.16.73.26 ls -l &gt;&gt;remote.log

done

-------------
vastare