Sponsored Content
Top Forums Shell Programming and Scripting Remote login and running a script on multiple servers Post 302891455 by Don Cragun on Wednesday 5th of March 2014 11:37:08 PM
Old 03-06-2014
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:
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
All times are GMT -4. The time now is 02:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy