ssh command doesnot excute commands in the destination server


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers ssh command doesnot excute commands in the destination server
# 1  
Old 03-08-2011
Java ssh command doesnot excute commands in the destination server

Hi All,

I have the below code where Iam connecting from xzur111pap server to xzur0211pap server thru ssh to execute some commands.
Code:
ssh xzur0211pap
spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
spaceleft=${spaceleft%\%}
if [[ $spaceleft -gt $danger ]]; then
   echo "ALERT : HUFS(/home $spaceleft)"
exit 0
fi

When I run this Iam successfully connecting to xzur0211pap but the commands are not being executed and the control never comes back to xzur111pap..

Can someone help.

Many thanks in advance.

Last edited by vbe; 03-09-2011 at 10:59 AM.. Reason: you insert between the code tags...Regards
# 2  
Old 03-09-2011
You know? It does help to know the OS and version for df may have not the same output.. and so understanding what you expect for an output can be tricky:
Code:
On HP-UX:

ant:/home/vbe $ df -k /home |tail -1 | awk '{print $5}'

ant:/home/vbe $ df -k /home
/home                  (/dev/vg00/lvol5       ) :   492845 total allocated Kb
                                                    108035 free allocated Kb
                                                    384810 used allocated Kb
                                                        78 % allocation used
ant:/home/vbe $ df -k /home |tail -1 
                                                        78 % allocation used
ant:/home/vbe $ spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
ant:/home/vbe $ 

.
.
Now AIX:
n12:/home/vbe $ df -k /home |tail -1 | awk '{print $5}'
4795
n12:/home/vbe $ spaceleft=`df -k /home |tail -1 | awk '{print $5}'`
n12:/home/vbe $ spaceleft=${spaceleft%\%}
n12:/home/vbe $ echo $spaceleft
4795

# 3  
Old 03-10-2011
Hi its an a linux machine..
# 4  
Old 03-10-2011
Not user I understand your request...
Is it a script in which you put ssh then the rest of commands?
I which case I would say once ssh got executed you have also a new shell on remote box that knows nothing of what is following...
You should rewrite your script and remove the ssh part, look at the man pages of ssh for the correct syntax to pass when wanting to pass commands
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

2. Shell Programming and Scripting

Command / Script to create touch file in destination server

Hello Team, Is there any Linux command / script available so that, I could create a simple 0 byte file in destination server by issuing the command from source server. If yes, Could you please let me know the possible solutions. in other words I just want to create a touch file in my home... (1 Reply)
Discussion started by: madhuraju
1 Replies

3. Shell Programming and Scripting

How to run commands on remote server using ssh password less authentication?

Hi, I need to run a script located in a directory on remote server by using ssh authentication from my local unix server. Can anyone help me in this. I have tried the below command. It worked for echo command but when i tried to open a file using cat command it is showing "cat: cannot open... (6 Replies)
Discussion started by: ssk250
6 Replies

4. Shell Programming and Scripting

Running Commands on a Remote Linux Server over SSH

Hello, I'm trying to create a ksh script to ssh to a remote server, enter the password and a couple commands. For security reasons I have changed the login, password and ip in my example. #!/bin/ksh ssh -t -t username@12.5.5.3 << EOF password cd bin pwd EOF When I run it. It... (5 Replies)
Discussion started by: seekryts15
5 Replies

5. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

6. Shell Programming and Scripting

executing commands in remote server using ssh

I have some commands which need to be executed in remote machine. I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Discussion started by: maitree
7 Replies

7. Shell Programming and Scripting

logging into server and excute commands

hi all, I am new to unix and unix scipting. i need a script to logging into servers and to excute some commands in each server. for eg : I tried with below script ,but cant get the desired o/p. please help with this for i in `cat serverlist` do echo $i ssh $i uname -a ; cat... (4 Replies)
Discussion started by: sudharson
4 Replies

8. Cybersecurity

prevent user from excute command

Dears I want to prevent users from doing spesific command "history -c" or "history" in general How can I do ? (4 Replies)
Discussion started by: reaky
4 Replies

9. Solaris

Require some way or shell in which commands doesnot gets logged in history file

Guys, can u tell me some way in which the commands i execute on solaris system doesnot gets logged. It should not appear in history file.. Is there any shell which provide such solution or can I turn off the logging, if yes then how... Help will be appreciated Thanks (2 Replies)
Discussion started by: harpreetrekhi
2 Replies

10. UNIX for Dummies Questions & Answers

PS command doesnot display shellscript runningi

PS command doesnot display shellscript runningi have written a small shel script to check for idsk space and log it to a file evry 300s.this so this run is a loop. But i want to start stop this script from another script using ps -ef grep but ps -ef is not displaying the script in output, if i... (1 Reply)
Discussion started by: mpauls
1 Replies
Login or Register to Ask a Question