The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 07:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 07:12 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-18-2006
Registered User
 

Join Date: Dec 2005
Posts: 19
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-18-2006
Registered User
 

Join Date: Dec 2005
Posts: 19
rsh problem

Hi,

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

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

------------
vastare
Reply With Quote
  #3  
Old 01-19-2006
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
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 ...
Code:
(rsh servername "jobname" < /dev/null > /dir/file 2>&1 &)
Reply With Quote
  #4  
Old 01-19-2006
Registered User
 

Join Date: Dec 2005
Posts: 19
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

2. 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

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

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

5. 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.

6. 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

7. 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
Reply With Quote
  #5  
Old 01-19-2006
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
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 ...

Code:
while true
do
    ls -l /dir/file
done
Reply With Quote
  #6  
Old 01-20-2006
Registered User
 

Join Date: Dec 2005
Posts: 19
rsh problem

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 >&/dev/null </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.



Ex:

while true
do

#rsh -n remote-IP command >>logfile
rsh -n 172.16.73.26 ls -l >>remote.log

done


-------------
vastare
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0