Remote login and running a script on multiple servers


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Network Remote login and running a script on multiple servers

Hi all,
I am baffled on this. Solaris Irix system.Smilie
I have 4 servers all connected to one another, Smilie I need to write a script line that would login on to server 1-3 ($HOST) start a script in the back ground and log off while the back ground script runs over a length of time.Smilie

say a script that has
Code:
pmem >> outputfile.txt

more lines yet but this output to file on the same server.

Now we can rlogin and start the script the script uses outputs and input feeds that makes this difficult to deal with due to that the log off turns off the script.Smilie i dont get it either but somehow it does.

restrictions:
I am only allowed to use tsch, sh (preferred Smilie) I can't use ssh its not implemented in the servers nor can it get implemented Smilie. I cant use or pass to, on any script, ip address, passwords or user namesSmilie. They are linked I can use rlogin hostname to get in any machine vita xterm. This is not a new setup its been running for years. Smilie

idea has been so far but Im new at this so Smilie
Code:
rsh $HOST 'nohup $process.sh >/dev/null > 2>&1 &'

this line does not work Smilie

thanks in advanceSmilie, I will try to get back here as much as possible to answer questions.
# 2  
And when you run the command:
Code:
rsh $HOST 'nohup $process.sh >/dev/null > 2>&1 &'

what on the system identified by $HOST is going to define the variable named process?

If you want to know what is going wrong, why are you redirecting all diagnostic messages to /dev/null?
# 3  
Hi Don,
What we are trying to create is a master script to run other scripts in the back ground on different machines.

to answer your questions
Code:
$host

are the host names of the 3 machines ws1 ws2 ws3. and
Code:
$process.sh

is the script name located on the NIS server which is the 4th machine making the initial call script. So all machines can see and access the script and its not written on each machine saving up needed space.

hope that answered the questions: now I have got some interesting results with the code for rsh

host names are config with Csh which is stty not supported for transit. (not sure what I just said but hope it helps)
and i have a ambiguous output redirect.

IE @Don you mentioned the direct to the null. Short answer is we don't care what the output is from the call, the script outputs to a different files those files are what we are after. But I think your right about having it directed to that null.

The rsh call stops and on the ws4 and creates a PID and waits until never (endless loop in script tracking memory) have to suspend and kill pid to stop it. again its not the problem but it stopping in the master script is.

any ideas I can research in to please throw them at me too. Thanks OJT scripting got to love it.
# 4  
You didn't even come close to answering my question. In the script:
Code:
rsh $HOST 'nohup $process.sh >/dev/null > 2>&1 &'

The rsh utility runs the command nohup $process.sh >/dev/null > 2>&1 & on the host specified by the expansion of$HOST. Since the string $process is given to rsh inside single quotes, $process will be expanded on the system specified by the expansion of $HOST; not on the system where you run the rsh command.

I repeat my question: What defines the value that $process will expand to on the hosts ws1, ws2, and ws3.

If process is being defined on the system where you're running rsh and not on ws1, ws2, and ws3, the command you're running on those systems is:
Code:
nohup .sh >/dev/null > 2>&1 &

Do you have any proof that the program that you want to run on ws1, ws2, and ws3 has been started?

Try running:
Code:
rsh $HOST 'nohup $process.sh >/dev/null > &'

which is likely to be a syntax error, but now you stand a chance of seeing the syntax error. Then try running:
Code:
rsh $HOST 'nohup $process.sh >/dev/null &'

which doesn't have any syntax errors, but I'm expecting you'll see an error message something like:
Code:
.sh not found

Then try running:
Code:
rsh $HOST "nohup $process.sh >/dev/null > 2>&1 &"

which will expand both $HOST and $process on the local system.
This User Gave Thanks to Don Cragun For This Post:
# 5  
Hi Don,

so the
Code:
$process

is the script .sh,
Code:
$process.sh

I think your mistaken the variable script name for a name variable and then a script. they are both the same. of course i could put the hard coded name in there but its a script running it and using proper programming you should use variables when or if it changes. sorry for any miss understandings.

Quote:
The rsh utility runs the command nohup $process.sh >/dev/null > 2>&1 & on the host specified by the expansion of $HOST . Since the string $process is given to rsh inside single quotes, $process will be expanded on the system specified by the expansion of $HOST ; not on the system where you run the rsh command.
correct this is what we want to be done. one script telling another script to run in the back ground of another machine and not on the originator.

Quote:
Do you have any proof that the program that you want to run on ws1, ws2, and ws3 has been started?
yes they are all in the same room and i can just run
Code:
ps -ef | grep  <process name>

on each of the work stations 1-3, addition to this I can run the rsh through the xterm however it will hang open on the main computer/ ws4 (work station 4) which will stop after ws1 and not run the script on ws2 or ws3.

Quote:
Then try running:

Code:
rsh $HOST "nohup $process.sh >/dev/null > 2>&1 &"
which will expand both $HOST and $process on the local system.
I'm confused with this can you elaborate. why will it run on the local system or will the process call run on the local system while the process script runs on the host system.

thanks
# 6  
Let me try once more.

Text inside single quotes such as $process in the command:
Code:
rsh $HOST 'nohup $process.sh ... &'

will not be expanded on the local system.
Code:
HOST=ws1
process=abc
rsh $HOST 'nohup $process.sh >/dev/null &'

will run the command:
Code:
nohup $process.sh > /dev/null &

on ws1. However, if you use double quotes instead of single quotes:
Code:
HOST=ws1
process=abc
rsh $HOST "nohup $process.sh >/dev/null &"

will run the command:
Code:
nohup abc.sh > /dev/null &

on ws1.

I repeat for the last time: Since you are using single quotes, how is the variable process defined on the remote systems so that it will be an exported variable in the environment of the shell started by rsh on those remote systems?
# 7  
Quote:
Originally Posted by Don Cragun
You didn't even come close to answering my question. In the script:
Code:
rsh $HOST 'nohup $process.sh >/dev/null > 2>&1 &'

The rsh utility runs the command nohup $process.sh >/dev/null > 2>&1 & on the host specified by the expansion of$HOST. Since the string $process is given to rsh inside single quotes, $process will be expanded on the system specified by the expansion of $HOST; not on the system where you run the rsh command.

I repeat my question: What defines the value that $process will expand to on the hosts ws1, ws2, and ws3.

If process is being defined on the system where you're running rsh and not on ws1, ws2, and ws3, the command you're running on those systems is:
Code:
nohup .sh >/dev/null > 2>&1 &

Do you have any proof that the program that you want to run on ws1, ws2, and ws3 has been started?

Try running:
Code:
rsh $HOST 'nohup $process.sh >/dev/null > &'

which is likely to be a syntax error, but now you stand a chance of seeing the syntax error. Then try running:
Code:
rsh $HOST 'nohup $process.sh >/dev/null &'

which doesn't have any syntax errors, but I'm expecting you'll see an error message something like:
Code:
.sh not found

Then try running:
Code:
rsh $HOST "nohup $process.sh >/dev/null > 2>&1 &"

which will expand both $HOST and $process on the local system.
Thats a good explanation to make people learn. seldom find people trying to help learn Smilie
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #463
Difficulty: Medium
chrony is an implementation of the Network Time Protocol (NTP) and is a replacement for the ntpd.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error running grep on Remote Servers

Im running the below command sshpass -p mypassword ssh -t user1@server2 /bin/bash -c 'echo "mypassword" | sudo -S -l; echo "$?#`grep -iE "user66|dbuser|tomcat|splunk|stash|jira|user2|docadmin" /etc/passwd`"; exit' Below is the error I get: Output: I run this command across a... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Shell Programming and Scripting

Running a script on remote server kills my login session

Hi there, I'm trying to run a script remotely on a server in a particular directory named after hostname which already exists, my login session gets killed as soon as I run the below command. Not sure what is wrong, is there a better way to do it ? Note: I can also use nohup command to run... (14 Replies)
Discussion started by: mbak
14 Replies

3. Shell Programming and Scripting

Running set of commands in remote servers in shell script

Hi Wishing to all. I am very new joined in an organization as a unix system administrator. I need a help in preparing a script for a report. i have a file contains all of the linux/ubuntu servers line by line around 140 servers. vi servers.txt nh01 nh02 nh03 bh01 bh04 - - :wq (3 Replies)
Discussion started by: kumaraswamy
3 Replies

4. Shell Programming and Scripting

Shell script using expect to login to couple of remote servers and read "crontab -l"

I need a shell script using expect to login to couple of remote servers and read "crontab -l -u <username>" & "cat /etc/rc.local" & "df -h" and able to create output into a file saved locally with hostname.crontab & hostname.rc.local & disk.status. I can supply a file as list of hostname or IP... (4 Replies)
Discussion started by: jaipsharma
4 Replies

5. Solaris

Remote execution of a local script on multiple servers

So I have a scriptlet called solaris_command: for i in \ server1 server2 server3 do echo $i ssh $i $1 echo "" done I then use that as a command in multiple scripts to allow for data gathering for all virtual hosts in the environment thusly: solaris_command "cat... (3 Replies)
Discussion started by: os2mac
3 Replies

6. Shell Programming and Scripting

Running a script on multiple remote hosts at once

I have a script on about 15 hosts that I need to run for each host whenever I want (not crontab). Problem is, this script takes 5-10 mins to run for each host. Is there a way I can run the script in parallel for all the hosts instead of 1 at a time? Also, I'm remotely running the script on the... (3 Replies)
Discussion started by: mrskittles99
3 Replies

7. Shell Programming and Scripting

Prevent wrong user from using shell script for multiple remote servers

Hi, I am running a shell script from a central server to multiple remote servers using the following code: application_check() { # Linux/UNIX box with ssh key based login SERVERS=`cat /tmp/server-details` # SSH User name USR="user" # create new file > /tmp/abc.log # connect... (2 Replies)
Discussion started by: mystition
2 Replies

8. UNIX for Dummies Questions & Answers

Running the same remote script on multiple servers

Experts, Im trying to remote into a server, run a script that resides on that server and capture the information displayed & store in a local file. I struggled with this yesterday & finally that script is working now. Now, here is a scope creep and the script that I wrote for 1 remote... (2 Replies)
Discussion started by: OMLEELA
2 Replies

9. Shell Programming and Scripting

login into multiple servers through script is having some problem

Hi Everybody, I am bit new to shell scripting. I need some help in my script. I have to login into 15 servers and check some logs daily. For that I've written one shell script, somewhere it is having some problems. After log into the first server, the script is not going with the next steps.... (6 Replies)
Discussion started by: raghu.iv85
6 Replies

10. Shell Programming and Scripting

login into multiple servers thru script...

I need to login into multiple servers thru a script run couple commands and run find command as root. I only have ssh access to the servers as a user than I can "su" to root. If you have a similar script please post it. Also if you can suggest commands that I should consider please let me know. ... (1 Reply)
Discussion started by: avcert1998
1 Replies

Featured Tech Videos