Run script from another server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run script from another server
# 1  
Old 10-15-2010
Run script from another server

If i have one server processing some feeds and creating a database. Then i want to copy the relevant tables from the first server to the second server. I have a shell script to do the copy. I was going to make a cron to run the script at a certain time. But it would not be ideal. I really want to somehow make absolutely sure that the first server has finished processing the feeds before the second server runs the DB import script. So rather than using a cron i wondered if there was a simple way to start the process from other server.

I guess i could use a password protected web page to achieve this. But i wondered if there was a nice way in unix?
# 2  
Old 10-15-2010
You could always rcp a dummy file on second server when first has finished its processing...
And use cron for checking the presence of dummy (dont forget to remove it after...) and launch the import on the second server...
If you know its just a question of waiting, you could schedule at fixed time and in your cron script testing the presence of dummy, if not found reschedule using at command
# 3  
Old 10-15-2010
You can use SSH to execute a command on the remote server.
Code:
echo "<your command here>" | ssh -C -l <user> <host>
if [ ${?} -ne 0 ]
then
      echo "ERROR: Command failed."
else
      echo "INFO: Command successfull."
fi

Regards.
# 4  
Old 10-15-2010
Thanks for your reply's. With the ssh method how do i supply password for the ssh function.

Would it be
Code:
echo "sh /scripts/myscript.sh" | ssh -C -l username:password 24.212.39.32
if [ ${?} -ne 0 ]
then
      echo "ERROR: Command failed."
else
      echo "INFO: Command successfull."
fi

I know when i run rsync scripts i dont need the passwords. Maybe this is the same?
# 5  
Old 10-15-2010
Quote:
Originally Posted by timgolding
I know when i run rsync scripts i dont need the passwords. Maybe this is the same?
.... because you have already set up and installed your public and private key pairs which were created without a password.

You can set this up the same way for SSH, BTW (that is if the keypairs you generated for rsync will not work for ssh, which I am not sure of without doing some research).
# 6  
Old 10-15-2010
I am not sure if there is another way, but if when you use rsync, it is over SSH, probably, as commented by NEO, you already have keypairs setup, so you will not need to provide a password.

If you want to know how keypairs setup work, check this link: OpenSSH Public Key Authentication

I hope it helps.
# 7  
Old 10-19-2010
I tried this and it asked for a password i guess the key pairs are not set up for ssh. Does this mean my rsync uses rsh. How can i find this out? Here is what i put

Code:
echo "sh /home/scripts/test.sh" | ssh -C -l root 24.212.39.32
Pseudo-terminal will not be allocated because stdin is not a terminal.
Password:

I entered the root password and the script ran.
Should i set up the keypairs with ssh or should i supply the password in the ssh command if i can?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

2. UNIX for Dummies Questions & Answers

Script to run in vio server

I want to grab all the luns in vscsi disks from vio that are assigned to client lpars. They are not powerpath disks. Now when I do lspv as root in vio server I see 956 disks..the problem right now is that each disks lun are in hex so when I do lscfg vpl from vio..the FRU number is on hex. Can... (3 Replies)
Discussion started by: pregmi
3 Replies

3. Shell Programming and Scripting

Need script to run the command in remote server

hi, I need script to perform below task. 1. Read the IP address 2. copy the script from origin server to destination. 3. get root access on destination server 4. run the script on destination server 5. return to the origin server Code: #!/bin/bash echo "Enter Server IP... (5 Replies)
Discussion started by: bapu1981
5 Replies

4. AIX

Run nmon on other server through script

Hai All, Iam new to AIX unix. Im just tryin to automate my monitoring work and hence i have writen a basic script in which i am running nmon on multiple nodes from a main node. say for ex: From server a : ssh server b nmon -MB -s1 -c1 > nmon_now.txt gave the password and... (7 Replies)
Discussion started by: jayadeava
7 Replies

5. Shell Programming and Scripting

Need help on how to exit a script run on a server from a remote server

hi, I am using the below line to run a script from remote server(say server A) to another server(say server B). ssh username@servername ksh script name. The issue is the script logs into server B, executes the script on server B, transfers the file to server A but does not exit from... (4 Replies)
Discussion started by: yohasini
4 Replies

6. Programming

Expect script to run a Shell script on remote server

Hi All, I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands. spawn ssh $uid@$host expect "password:" send "$password\r" expect "*\r" send... (2 Replies)
Discussion started by: yashwanthsn
2 Replies

7. Shell Programming and Scripting

How can i run script on other server.

Hi guys , I want to run a specific command from one server to another. For example I have a server called A(client) and a server called B(Server). How would i fire a command on Server(B) while working on Client(A). One way of doing it is using ssh "ssh -tq 10.180.8.231 ls -ltr" but... (3 Replies)
Discussion started by: pinga123
3 Replies

8. Shell Programming and Scripting

Run shell script on another server using ssh

Hi, I have 2 servers and i installed ssh2 on both boxes .. so they they can communicate with each other with our password auth .. now i want to write a scrip on box 1 for running commands and getting out put from the second box can some one help me out Thank you in advance (1 Reply)
Discussion started by: anwesh
1 Replies

9. Solaris

I want to run a script or command on other server

Hi all, I have done ssh-keygen to two servers in work place and given there entry for authorized_keys. I m able to ssh to other servers without asking password. But i face problem while trying to run a command or script on other server. It is throwing an Error. $ ssh... (4 Replies)
Discussion started by: naree
4 Replies

10. Shell Programming and Scripting

run a application from a remote server via script?

I have a ksh script that does a bunch of things, then runs telnet server_b I then manually login, manually run one command (which launches an application with display back to my workstation), then logout at which point the main script takes back over, runs something else, then ends. Is... (4 Replies)
Discussion started by: yankee428
4 Replies
Login or Register to Ask a Question