Remote login and running a script on multiple servers
Hi all,
I am baffled on this. Solaris Irix system.
I have 4 servers all connected to one another, 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.
say a script that has
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. i dont get it either but somehow it does.
restrictions:
I am only allowed to use tsch, sh (preferred ) I can't use ssh its not implemented in the servers nor can it get implemented . I cant use or pass to, on any script, ip address, passwords or user names. 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.
idea has been so far but Im new at this so
this line does not work
thanks in advance, I will try to get back here as much as possible to answer questions.
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
are the host names of the 3 machines ws1 ws2 ws3. and
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.
You didn't even come close to answering my question. In the script:
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:
Do you have any proof that the program that you want to run on ws1, ws2, and ws3 has been started?
Try running:
which is likely to be a syntax error, but now you stand a chance of seeing the syntax error. Then try running:
which doesn't have any syntax errors, but I'm expecting you'll see an error message something like:
Then try running:
which will expand both $HOST and $process on the local system.
This User Gave Thanks to Don Cragun For This Post:
so the
is the script .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
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.
Text inside single quotes such as $process in the command:
will not be expanded on the local system.
will run the command:
on ws1. However, if you use double quotes instead of single quotes:
will run the command:
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?
You didn't even come close to answering my question. In the script:
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:
Do you have any proof that the program that you want to run on ws1, ws2, and ws3 has been started?
Try running:
which is likely to be a syntax error, but now you stand a chance of seeing the syntax error. Then try running:
which doesn't have any syntax errors, but I'm expecting you'll see an error message something like:
Then try running:
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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)