|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hide the output of spawn ssh user@server
Hi All, I have written one script, which is connecting 3 diffrent servers and executing script placed on those. It is smthing like: Code:
spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof spawn ssh user@server2 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename2 \r" expect "$" expect eof spawn ssh user@server3 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename3 \r" expect "$" expect eof But problem I am facing here is that: On console I am getting lots of unwanted outputs of spawn ssh user@server1 and spawn ssh user@server2 and spawn ssh user@server3 along with those scripts (file1, file2, file3) responses. where as i need just outputs of : send " sh ./filename1 \r" send " sh ./filename1 \r" send " sh ./filename3 \r" So could you please suggest any solution for this? Thanks in advance! Regards, KD Last edited by Scrutinizer; 02-11-2013 at 06:51 PM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Have you tried using /dev/null to silence the output? Maybe something like this for what you need removed from the output: Code:
send "pw \r" > /dev/null |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
You should try this: Code:
( spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof ) > /dev/null ( spawn ssh user@server2 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename2 \r" expect "$" expect eof ) > /dev/null ( spawn ssh user@server3 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename3 \r" expect "$" expect eof ) > /dev/null |
|
#4
|
|||
|
|||
|
Hi,
First of all thanks for suggesting the solution. But these solutions are not able to resove the problem. both the suggestions are giving some errors. Could any one suggest the appropriate solution? Regards, KT |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
How to hide connection response during ssh user@server?
I tried following options, but dint find solution: Code:
send "pw \r" > /dev/null and Code:
( spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof ) > /dev/null Thanks in advance! Regards, KD
Last edited by Scrutinizer; 02-11-2013 at 06:52 PM.. Reason: Removed duplicate content |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
By default, spawn echoes the command name and arguments. The
-noecho flag stops spawn from doing this. Man Page for expect (all Section 1) - The UNIX and Linux Forums It is better security and simpler scripting to set up key files for PPKey and just shell script the ssh. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Try this:, However note that all output will be hidden. Code:
( /usr/bin/expect <<EOD spawn ssh user@server1 expect "*? assword:" send "pw \r" expect "$" send " sh ./filename1 \r" expect "$" expect eof EOD ) > /dev/null 2>&1 |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| User Input Automation without Spawn | foghsho | Shell Programming and Scripting | 8 | 05-16-2012 02:26 AM |
| Help to hide shell terminal and run prompt program after ssh login for specified user | franzramadhan | Shell Programming and Scripting | 1 | 09-29-2011 05:30 AM |
| passwordless entry using ssh from one user to a different user on the same server | deshaipet | AIX | 3 | 08-20-2011 09:04 AM |
| ssh for different user account in a server configuration | posix | UNIX for Dummies Questions & Answers | 1 | 04-09-2011 07:19 PM |
| spawn a process with a different user | edgarvm | Programming | 8 | 11-09-2010 02:43 PM |
|
|