Commands not running after automated logon


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Commands not running after automated logon
# 1  
Old 10-06-2010
Commands not running after automated logon

Hi Frnds,

I was able to do passwordless ssh with the help of public key fundamental , i tried it out on my script but the problem is that the script stops after logging to the server and does not run any commands .But when i exit from that server the command runs automatically after that. Have a look at the script and the output --

Code:
nssh# cat module.sh
sleep 1
ssh nsadm@10.49.10.7; ls -lrt

nssh# ./module.sh
Last login: Wed Oct 6 15:53:24 2010 from 10.49.10.4
nssh#
nssh# exit
exit
Connection to 10.49.10.7 closed.
total 48
-rw-r--r-- 1 nsadm nsadms 570 Sep 29 12:47 test.txt
-rw-r--r-- 1 nsadm nsadms 5924 Sep 30 10:38 out
-rw-r--r-- 1 nsadm nsadms 1118 Oct 5 11:26 id_dsa2.pub
-rw------- 1 nsadm nsadms 1264 Oct 5 11:26 id_dsa2
-rw-r--r-- 1 nsadm nsadms 6 Oct 5 12:03 LDAP.pwd
-rwxrwxrwx 1 nsadm nsadms 280 Oct 5 12:08 ss.sh
drwxr-xr-x 2 nsadm nsadms 4096 Oct 5 17:54 Logging
-rwxrwxrwx 1 nsadm nsadms 9038 Oct 5 17:55 gaurav.sh
-rwxrwxrwx 1 nsadm nsadms 40 Oct 6 15:53 module.sh
:eek::eek::confused:

rgds
G.C

Last edited by Scott; 10-11-2010 at 07:15 AM.. Reason: Please use code tags
# 2  
Old 10-11-2010
Hi.

You are running two commands here (separated by the semi-colon):

Code:
ssh nsadm@10.49.10.7; ls -lrt

ssh nsadm@10.49.10.7 run like this will log you on to the remote computer, to an interactive shell, and when you exit, ls -lrt runs on the local computer

The command should be:
Code:
ssh nsadm@10.49.10.7 "ls -lrt"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Run automated bash commands from sh login shell

I use plink.exe to automate remote commands that return data to Windows machines. This works well on newer servers running Red Hat since the commands were developed for bash and the designated user's login shell is bash. I need to also support older servers which are running Solaris 10 but the... (5 Replies)
Discussion started by: randman1
5 Replies

2. Shell Programming and Scripting

Running two commands in background

Hi I want to run two commands in background, i am using below way, but it is not working, i m calling these two commands from one script to another server where below commands are running, in my script ssh is working fine, but command is not going in background, please advise what should i do. ... (10 Replies)
Discussion started by: learnbash
10 Replies

3. Shell Programming and Scripting

Automated logon within shell scripts

Hi All, I have created a server health checkup for 22 diferent ips and want to run my script from a single host server -->conduct health chekup on various servers--> Capture the deviations--> Get back all the deviations to the host server where the script was initiated. Ive checkd out ssh... (3 Replies)
Discussion started by: gemnian.g
3 Replies

4. Shell Programming and Scripting

Code for running commands one after other

I need an if code in shell script where it should continue to further commands after succesfully installing the executable file. i.e. /run installer is continuing but in the middle it executes further commands like "cp /root/user which were given after /run installer. I want /runinstaller... (16 Replies)
Discussion started by: sriki32
16 Replies

5. Shell Programming and Scripting

For loop and running 2 commands at once?

HI. I am trying to run 2 commands, using the "for x in a b c d" loop but i am having a hard time coding it... Here is what i have so far: for SERVER in SERVERA SERVERB SERVERC SERVERD SERVERE do ############################################################################### #... (5 Replies)
Discussion started by: Stephan
5 Replies

6. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

7. Programming

Running shell commands from C/C++

Hi guys, I know using system() we can run unix commands but the problem is, I can't get any returns with the system(). I am returning stuff from my shell scripts that I need to be able to read from my C code. Anybody has cure to this problem? :)) Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

8. Programming

Running UNIX Commands from C

Hi, -How can I get number of files, cpu usage (percentage), memory usage, disk usage, ...etc, using C program ... I can use unix command ( system(command) )but I want the value to be returned back to my C program to use it in my code? How can I do that? Thanks in advance ... (2 Replies)
Discussion started by: zainab
2 Replies

9. Shell Programming and Scripting

running commands from outside of bash

Hello all! I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this? Anyone can do something for my query? Click here if you can't understand my query or to know the need for this query. (3 Replies)
Discussion started by: rakabarp
3 Replies

10. UNIX for Dummies Questions & Answers

running start up commands

Hi all How can I setup my shell so that I run a set of commmands or a script every time I login. I am using kshell. I tried putting a line in ./.bash_profile (does not work) Ex.: I want to use vi as the commandline editor so, I want to run the command: set -o vi (3 Replies)
Discussion started by: skotapal
3 Replies
Login or Register to Ask a Question