remove output Connection to $server closed.
I am running a script that ssh to a machine and ls a folder
var=`ssh -t $server $command` echo $var but the output i am getting contains the line Connection to $server closed. how can i remove this line? Can anyone please help? |
Quote:
var=`ssh -t "$server" "$command"` echo $var |
Quote:
i still get the connection to server closed i dont want the line beacause i am generating a report afterwards Can i redirect the line ine some way not to get the Connection to swerver closed? Please help |
Quote:
I am not able to get you clearly |
Quote:
Command var=`ssh -t $server "ls /"` output on screen Connection to $server closed. I want to remove this line Connection to $server closed |
Quote:
use server=ip_address. I am getting same problem when I used $server as domain name.(abc.com) I will show you my test script. linux@tuxworld:~$ cat test.sh #!/bin/bash server="1.1.1.1" cmd="ls -la" var=`ssh root@$server "$cmd"` echo $var linux@tuxworld:~$ This script is working for me |
Quote:
thnks for helping Sharad but i need to ssh using the dns name I do not have control on the ip ands the ip keeps changing Can you suggest a way where i can redirect the <<Connection to server closed>> to /dev/null or to any other file |
Quote:
it creates another tty I am using parameter -t as i do not have root access on the server |
Quote:
linux@tuxworld:~$ cat test.sh #!/bin/bash server=`nslookup abc.com|grep -A 3 abc.com|grep Address|awk '{print $2}'` cmd="ls" ssh -t username@$server $cmd linux@tuxworld:~$ first of all check this command, are you able to get ip address with below command .if successful then run test.sh script. nslookup abc.com|grep -A 3 abc.com|grep Address|awk '{print $2}' |
Quote:
thanks for helping Sharad but i can only use the dns name Can you please suggest another way without resolving the dns to its corresponding ip |
Quote:
Give the answer of below two questions- (1)Have you tried the script which I pasted and what was the output.Is it working or not. (2)Does your server have multiple ip , just like if you do nslookup google.com . |
Quote:
linux@tuxworld:~$ cat test.sh #!/bin/bash server='your_domain_name.com' cmd="ls" ssh -t username@$server $cmd linux@tuxworld:~$ |
All times are GMT -5. The time now is 10:23 PM. |