Sponsored Content
Top Forums Shell Programming and Scripting Hide the output of spawn ssh user@server Post 302768749 by dexdex200 on Saturday 9th of February 2013 12:16:38 PM
Old 02-09-2013
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

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need to hide output to screen

I have a script that askes users to enter in an oracle account and password, The information is displayed on the screen as they type it. Does anyone know how I can hide this output? :confused: (1 Reply)
Discussion started by: boat73
1 Replies

2. Solaris

How to hide SSH version

I just been audited and one the recommendations is to hide the SSH version or give fake information. I went to openssh.com they don't seem to have any info on how to fix this :confused: Anybody knows how the heck can I hide the SSH version? The part which says # telnet localhost 22... (19 Replies)
Discussion started by: sparcguy
19 Replies

3. Shell Programming and Scripting

[SSH] Need to connect to remote server as different user and without password

I have a task requiring that USER_A run a script, which connects to HOST_B as USER_B and does not ask for a password. If I am logged in on HOST_A as USER_B, I can connect to HOST_B without a password, no problem. However, if I try running ssh with the command line "ssh USER_B@HOST_B" while... (3 Replies)
Discussion started by: Totengraber
3 Replies

4. Programming

spawn a process with a different user

Hello Everyone: I have the following code int main() { system("/usr/OtherUser/bin/runX"); return 0; } runX must be executed with privileges from another user, how could I do that? I know the password for such user. Thanks in advance (8 Replies)
Discussion started by: edgarvm
8 Replies

5. UNIX for Dummies Questions & Answers

ssh for different user account in a server configuration

Hi team, I am not able to configure the ssh settings for a UserA to do ssh or scp to the UserB in the same server , what could be the best way to do the ssh form UserA to UserB. I've generated the public key in UserA ~/.ssh and kept a copy of that in ~/.ssh of authorized_key of UserB . Still... (1 Reply)
Discussion started by: posix
1 Replies

6. AIX

passwordless entry using ssh from one user to a different user on the same server

Hi, We have a requirement to do passwordless entry from one user to a different user on the same AIX server using ssh keys. Can some one help me with this? Thanks in advance, Panditt (3 Replies)
Discussion started by: deshaipet
3 Replies

7. Shell Programming and Scripting

Help to hide shell terminal and run prompt program after ssh login for specified user

Hey guys, I have some task from my office to lock user on the specified directory after the user logged on using ssh. And then run prompt program to fill the required information. Yeah, just like an ATM system. My question: How could I do those?? AFAIK I have to edit the ~./bashrc. But the... (1 Reply)
Discussion started by: franzramadhan
1 Replies

8. Shell Programming and Scripting

Email alerts whenever someone logs into server via SSH any user?

Hi all, Thanks in Advance!! I dont know how to start to write script for this process, my requirement is if any user logs into server automatically Admin get mail alert. how is this possible? any one guide me to complete this process. (1 Reply)
Discussion started by: anishkumarv
1 Replies

9. Shell Programming and Scripting

User Input Automation without Spawn

Hello All! I am attempting to create a shell script that will execute another shell script (mandatory by 3rd party software I'm attempting to automate). What I want to do is simply this, once the shell script is run, it will execute the other shell script (I have that done fine and working),... (8 Replies)
Discussion started by: foghsho
8 Replies

10. Shell Programming and Scripting

ssh user@server ' cd path;j=0; for i in *;do;d=`du -sh $i | awk '{print( $1 )}'`;p=$d'|'$i;j=`expr $

Please help me to resolve below the issue in script ssh user@server ' cd path;j=0; for i in *;do;d=`du -sh $i | \ awk '{print( $1 )}'`;p=$d'|'$i;j=`expr $j + 1 `;arr=$p;echo ${arr};done' (1 Reply)
Discussion started by: SAUD PASHA
1 Replies
EXPECT_EXPECTL(3)							 1							 EXPECT_EXPECTL(3)

expect_expectl - Waits until the output from a process matches one of the patterns, a specified time period has passed, or anEOFis seen

SYNOPSIS
int expect_expectl (resource $expect, array $cases, [array &$match]) DESCRIPTION
Waits until the output from a process matches one of the patterns, a specified time period has passed, or an EOF is seen. If $match is provided, then it is filled with the result of search. The matched string can be found in $match[0]. The match substrings (according to the parentheses) in the original pattern can be found in $match[1], $match[2], and so on, up to $match[9] (the limitation of libexpect). PARAMETERS
o $expect - An Expect stream, previously opened with expect_popen(3). o $cases - An array of expect cases. Each expect case is an indexed array, as described in the following table: Expect Case Array +----------+--------------------------+---+---+---+ |Index Key | | | | | | | | | | | | | Value Type | | | | | | | | | | | | Description | | | | | | | | | | | | Is Mandatory | | | | | | | | | | | | Default Value | | | | | | | | | | +----------+--------------------------+---+---+---+ | 0 | | | | | | | | | | | | | string | | | | | | | | | | | | pattern, that will be | | | | | | matched against the out- | | | | | | put from the stream | | | | | | | | | | | | yes | | | | | | | | | | | | | | | | | | T{ 1 | | | | | | | | | | | | mixed | | | | | | | | | | | | value, that will be | | | | | | returned by this func- | | | | | | tion, if the pattern | | | | | | matches | | | | | | | | | | | | yes | | | | | | | | | | | | | | | | | | T{ 2 | | | | | | | | | | | | integer | | | | | | | | | | | | pattern type, one of: | | | | | | EXP_GLOB, EXP_EXACT or | | | | | | EXP_REGEXP | | | | | | | | | | | | no | | | | | | | | | | | | | | | | | | EXP_GLOB | | | | | | | | | | +----------+--------------------------+---+---+---+ RETURN VALUES
Returns value associated with the pattern that was matched. On failure this function returns: EXP_EOF, EXP_TIMEOUT or EXP_FULLBUFFER CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 0.2.1 | | | | | | | Prior to version 0.2.1, in $match parameter a | | | match string was returned, not an array of match | | | substrings. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 expect_expectl(3) example <?php // Copies file from remote host: ini_set("expect.timeout", 30); $stream = fopen("expect://scp user@remotehost:/var/log/messages /home/user/messages.txt", "r"); $cases = array( // array(pattern, value to return if pattern matched) array("password:", "asked for password"), array("yes/no)?", "asked for yes/no") ); while (true) { switch (expect_expectl($stream, $cases)) { case "asked for password": fwrite($stream, "my password "); break; case "asked for yes/no": fwrite($stream, "yes "); break; case EXP_TIMEOUT: case EXP_EOF: break 2; // break both the switch statement and the while loop default: die "Error has occurred!"; } } fclose($stream); ?> SEE ALSO
expect_popen(3). PHP Documentation Group EXPECT_EXPECTL(3)
All times are GMT -4. The time now is 08:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy