run script accross machines using ssh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers run script accross machines using ssh
# 1  
Old 05-01-2011
run script accross machines using ssh

Hi all
I have to run certain set of commands on two machines, the two machines see the same home, it's mounted from the same place. The problem is that i have to ssh to a certain machine "which is slow unfortunately" that has the license to run a tool and i want to return to the original machine "which is strong one" to run the rest of commands that do not need i license so how can i launch a script from one machine, execute some commands and ssh to another machine and continue the rest of commands in the script, i want something like following


### I'm in machine1
run command1
ssh machine2
run command2


note: I log in to all the machines will the same account and i do not need to type the password, I have done something called passoff to disable asking for password when using ssh

thanks in advance
# 2  
Old 05-01-2011
I'm not sure to understand what you want, but as long as you don't have to use password on each call, so you have a private/public ssh key login type you can use ssh as anything else.
For example :

Code:
hostname2$ ssh hostname1 'ps aux' | grep apache

this will run ps aux on hostname1 and grep the output on hostname2.

Another example :
Code:
machine1$ ssh machine2 'command2' | command1

This will launch command1 on machine2 to process the output of command2 from machine2.
# 3  
Old 05-01-2011
first thanks for reply Smilie

I have a Q:

In the second code i think you mean it will run command1 on machine1 on the output of command2 on machine2, is that right ?
# 4  
Old 05-01-2011
Quote:
Originally Posted by amr elhosiny
first thanks for reply Smilie

I have a Q:

In the second code i think you mean it will run command1 on machine1 on the output of command2 on machine2, is that right ?
Right.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Load different lib paths for different machines during ssh.

Greetings to every one, I have to access different clusters for computing. But the problem is their lib paths are different. :eek: How can i export some particular library paths for a particular machine ? For example Like cluster_1 (ip : 10.169.85.47) export LD_libPATH="/opt/CUDA" Like... (2 Replies)
Discussion started by: admax
2 Replies

2. AIX

Passwordless SSH problem with AIX machines

Hello, I am trying to setup passwordless nophrase ssh between two machines for the user id: oraprod here is what I did for a non-root user: oraprod whoami: oraprod Machine A: ssh-keygen -t dsa cat ~/.ssh/id_rsa.pub # GO TO MACHINE B create (16 Replies)
Discussion started by: filosophizer
16 Replies

3. Shell Programming and Scripting

ssh run script error

Hello when try to excute the following ssh -l pla 10.287.60.55 vis_fil vis_fil not found. but it works fine when login to the server. can you help me run this command in one online because i will add later to shell script regards (1 Reply)
Discussion started by: mogabr
1 Replies

4. Shell Programming and Scripting

ssh - run shell script - Error

Hi Team, I am trying to run shell script from one server to another server with below command. ssh abc@pqr.america.com /tmp/test.ksh But, it gives below error. Can someone help me what is the issue? exec(): 0509-036 Cannot load program ssh because of the following errors: ... (3 Replies)
Discussion started by: ace_friends22
3 Replies

5. UNIX for Advanced & Expert Users

SSH connectivity between two machines with private key

Hi I have two machines Mac1 and Mac2 logging in with same user id and same private key. can anyone let me know how to connect these two machine using ssh . or SCP files to other machine :wall: (1 Reply)
Discussion started by: madankumar
1 Replies

6. Shell Programming and Scripting

ssh to run bash script

I want to use ssh to start a bash script that I have uploaded to a webhost. How do I do that from linux? (2 Replies)
Discussion started by: locoroco
2 Replies

7. UNIX for Advanced & Expert Users

Synchronize DataBase Table Between Machines Via SSH?

Hello I have 2 servers that need a database table to be one way synchronized (server A needs to push the table to server B) I considered using a FEDERATED DB, but decided against it for my particular application (Server B has several apps that would be calling the table repeatedly, and a... (3 Replies)
Discussion started by: kettlewell
3 Replies

8. Shell Programming and Scripting

Run function from script over ssh (BASH)

Hi, Is there any cleaver way to run function from the bash scrip over ssh? For example: #!/bin/bash #Function 1 FN1 () { ls -l } #Main run ssh user@host FN1 exit 0 Yeah, I know it will not work, but I'm asking how to make it to work :) I'm suspecting that it would be... (1 Reply)
Discussion started by: columb
1 Replies

9. Red Hat

application to be run on machines connected in same network

I have a set up of 5 machines which are connected in same network. Now i want to run a small application so that those machines are not ideal. (0 Replies)
Discussion started by: pradeepreddy
0 Replies

10. UNIX for Advanced & Expert Users

stagger ssh command to multiple machines

Good day, I am extracting information from Apache log files from 41 servers. Every day I have 7 cronjobs scheduled to do this for me and it works beautifully :D... only problem is that it takes about 6-9 hours to run through, as the script runs about 6 ssh commands for each box then goes to the... (3 Replies)
Discussion started by: msullivan
3 Replies
Login or Register to Ask a Question