scripts in another linux m/c via ssh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scripts in another linux m/c via ssh
# 1  
Old 08-21-2005
scripts in another linux m/c via ssh

I want to write a script which connects to another linux via ssh.
now i need to execute the rest of my script in that linux..

Quote:
#!/bin/bash
ssh 10.1.1.252
echo "asdfasdf"
exit
the echo is coming only when i exited from 10.1.1.252..

pls help
# 2  
Old 08-22-2005
You can execute a single command by adding it to the end of the ssh command line. For eaxmple:

ssh 10.1.1.252 "ls -l"

If you wish to execute multiple command you can separate then with semi colons. For example

ssh 10.1.1.252 "cd / ; ls -l"

Or you could put them all in a script on the remote machine. For example:

ssh 10.1.1.252 "$HOME/bin/myscript"
# 3  
Old 08-22-2005
you may have to set the display on the remote server to your local machine after you login

export DISPLAY=<machine name/IP>
# 4  
Old 08-22-2005
Quote:
Originally Posted by Unbeliever
You can execute a single command by adding it to the end of the ssh command line. For eaxmple:

ssh 10.1.1.252 "ls -l"

If you wish to execute multiple command you can separate then with semi colons. For example

ssh 10.1.1.252 "cd / ; ls -l"

Or you could put them all in a script on the remote machine. For example:

ssh 10.1.1.252 "$HOME/bin/myscript"
But the script ($HOME/bin/myscript) have to be there in the remote machine..
I want to execute the script which resides in my system...
# 5  
Old 08-22-2005
Then I'm afraid (as far as I know) you have to transfer the script to the target system before you can execute it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux startup and stop scripts using SSH

I have a question. Actually I want to make two scripts, one is startup.sh and other is stopscript.sh so for example, I have 5 servers. Each server has two instances :- abc111 - Masters -cra4 abc222 -middle tear -cra abc333 -middle tear -cra1 abc444 -middle tear ... (1 Reply)
Discussion started by: siddharthjain
1 Replies

2. Shell Programming and Scripting

Bash scripts - CGI and ssh

Hi Everyone, I started looking at the possibility of making some of our bash scripts available through a web server using CGI and the simple ones works just fine. Now I need to execute remote commands using ssh but can't really get it to work. I got private keys all sorted. Must be ssh... (1 Reply)
Discussion started by: arizah
1 Replies

3. Shell Programming and Scripting

Starting Scripts Using SSH

Hi all, Case 1: ./Myscript.sh param (on a first node) Another node: (In parallel i run the same script) ./Myscript.sh param (on a second node) Case2: From my host, using ssh: for i in $(seq $nb_lignes) (0 Replies)
Discussion started by: chercheur111
0 Replies

4. Shell Programming and Scripting

Validation of linux scripts

Hi, I have a script which invokes another script inside. Is there any way I can validate the script for syntax errors as well as checking if the files mentioned in the commands exist without executing it? Below is an example Example. ======================= Script1 #ksh echo... (3 Replies)
Discussion started by: krish000
3 Replies

5. UNIX for Dummies Questions & Answers

vnc over an ssh tunnel Linux to Linux to Windows

I *think* what I want to do is not only possible but easy, but as a "dummy" :) I can't figure it out. Here's what I have: Linux (Ubuntu 10.04) laptop that is not in my house, but has an Internet connection. Linux (Ubuntu 9.04) computer in my house that has unfettered access to the... (6 Replies)
Discussion started by: WesleyC
6 Replies

6. Shell Programming and Scripting

SSH - Passing Unix login passwords through shell scripts

Hi All , I need to call a script runscript_B.sh on server A, the runscript_B.sh script locating in server B. The runscript_B.sh in calls another script runscript_A on server A itself. it seend, i need to be connect from Server A to Server B using ssh. I have tryed like this in... (3 Replies)
Discussion started by: koti_rama
3 Replies

7. HP-UX

ssh scripts

hi, I need a script for transport a compressed files using ssh ( /oracle/JDD/oraarch.stanby filesytem ) in local server. and remote server also decompress these files and excute also in remote. (0 Replies)
Discussion started by: abozgul
0 Replies

8. UNIX for Dummies Questions & Answers

pulling scripts from unix to linux

:confused: I am working on transferring "good" running code scripts from unix to linux (suse). Some errors show in linux that are not present in unix. Specifically, the error code is: codename : no closing quote This is referring to the last line of the code + one line. I have used temporary... (3 Replies)
Discussion started by: pjconfig
3 Replies

9. Shell Programming and Scripting

use of ssh in scripts

Hi all.. My problem is i have some commands, some run in my linux machine, and the rest in another linux machine. I have to ssh to that machine.. how can i ssh with username and password in shell scripts.. can i use commands like thanks in advance (7 Replies)
Discussion started by: esham
7 Replies

10. UNIX for Dummies Questions & Answers

Linux Scripts

I'm pretty new to the world of linux, so no flames please. I know there is a plethora of info out on the internet about writing scripts for linux, but few give actual examples. I need some help with learning the basics of writing some simple scripts to learn the difference between windows and... (1 Reply)
Discussion started by: Strm2k
1 Replies
Login or Register to Ask a Question