expect

Expect Script Return Value

百般思念 提交于 2019-12-08 13:39:29
问题 I'm including simple Expect commands within a bash script (I know I could be just writing a pure Expect script but I would like to get it to work from within bash). The script is below: #!/bin/bash OUTPUT=$(expect -c ' spawn ssh mihail911@blah.org expect "password:" send "dog\r" ') Upon ssh'ing to the above address, it will return something of the form mihail911's password: on the prompt so I think my expect line is valid. When I run this my script does not print anything. It does not even

Call “expect” script in C++ process

爱⌒轻易说出口 提交于 2019-12-08 12:17:34
问题 I realized a shell using expect/spawn and send commands to SCP files from a remote server which send automatically the password when it is needed. The script works fine on UNIX terminal. Nevertheless, I tried to use this script throough a C++ process. It has been called by system() or even popen() function without sucess. This error is returned: "ioctl(raw): I/O error" Someone could have any clue? This is my script: #!/bin/bash targetHost=$1 password=$2 sourceFile=$3 destRep=$4 expect -c "

TCL/Expect:: How to automate the router boot loader function [duplicate]

落爺英雄遲暮 提交于 2019-12-08 12:04:09
问题 This question already has answers here : How to automate console scenario using TCL script? [closed] (2 answers) Closed 5 years ago . This Question is the continuation of My old question "TCL/Expect:: How to automate the router booting scenario?". Since I am not getting any response for that I am creating a new question. My requirement : I want to automate router boot prompt scenario. That involves following steps: Login into a router Give reload Press Esp kep from keyboard continuously (You

Linux expect send weird constructions

强颜欢笑 提交于 2019-12-08 11:17:29
问题 I am trying to figure out how expect working. AFAIK the expect script consists of "expect" and "send" statements. So for each approporiate "expect" statement which appears on screen the "send" statement is called. Also the command "interact" means that controlling is passed back to user and he is able to interact with the terminal. Correct me if I am wrong. Those two statements works like a charm. 1st: #!/usr/bin/expect spawn ssh -q localhost; # Handles following message: "Are you sure you

Expect script error send: Spawn id exp4 not open while executing

独自空忆成欢 提交于 2019-12-08 07:17:12
问题 I'm trying to run this script but having different errors when modified. Here is the code and the output. Please help. Updates at the end of the post with debug info #!/bin/bash (( $# != 1 )) && { echo >&2 "Usage: $0 \"[COMMAND]\""; exit 1; } servers_addresses=(10.10.10.10 ) for server_address in ${servers_addresses[@]}; do expect <<EOF spawn ssh -t root@$server_address "$*" expect -timeout 2 "Are you sure you want to continue connecting (yes/no)?" { send "yes\n" } expect "s password:" { send

linux + ssh limitation + ssh at the same time from multiple machine to one machine

杀马特。学长 韩版系。学妹 提交于 2019-12-08 06:45:26
the following script "testssh.ksh" proves that ssh have some problems when we try to perform ssh from multiple machines on the same time in fact the target of this script is to verify the file test_file under /var/tmp in the Solaris server (10.10.18.6) , as all see in some ssh steps we can’t verify the existing of the test_file because ssh stuck or not activate from the expect background - this script perform 15 times ssh to Solaris server with IP - 10.10.18.6 on the same time in order to verify the file_test under /var/tmp in the server my question - how to improve the ssh process in order to

ssh remote server login script

醉酒当歌 提交于 2019-12-08 04:53:06
问题 Currently I am trying to write a ruby script to logging-in SSH Remote Server using "pty" & "expect" ruby library. and also try to create new rails app inside the remote system using that script. Anyone can tell me. how logging-in to remote server using the ruby library ? 回答1: You should look at some of the examples for Net::SSH , it basically opens a connection and gives you a block to execute whatever command you like, e.g.: #!/usr/bin/env ruby require 'rubygems' require 'net/ssh' HOST =

Creating interactive options in pexpect

岁酱吖の 提交于 2019-12-08 03:34:43
问题 This is sort of a clunky question as I can't figure out a good way to describe it, but in expect you can do something like this: interact { \001 {do_something} \003 {do_something_else} "?" { set timeout 1 expect_user { "?" {send "?"} timeout {send_user "show a menu of the things you can do"} } stty raw -echo set timeout 60 } \035 {send "^]" send "quit\r" send_user "\n" exit } } which would create an interactive session where the user could go about business as usual, but upon pressing

Expect redirect stdin

半城伤御伤魂 提交于 2019-12-08 02:42:12
问题 I'm running a script on a remote server like using this command: ssh root@host 'bash -s' < script.sh Now I'm trying to use expect to handle the password prompt. This is the script: #!/usr/bin/expect set cmd [lindex $argv 0] spawn -noecho ssh root@host $cmd expect { "password:" { send "password\r" } } If I run the script, it gives no output: ./ssh.exp 'bash -s' < script.sh I know that's not the way to use ssh without password, but this is not the question right here. UPDATE I tried the idea of

expect script for remote ssh login and executing commands

被刻印的时光 ゝ 提交于 2019-12-08 00:59:33
问题 I am using following expect script for remote ssh login to raspberry pi and executing command #!/usr/bin/expect set timeout 60 spawn ssh [lindex $argv 1]@[lindex $argv 0] expect "yes/no" { send "yes\r" expect "*?assword" { send "[lindex $argv 2]\r" } } "*?assword" { send "[lindex $argv 2]\r" } expect "pi@raspberrypi ~ $ " { send "ls -la\r" } interact The problem is that this script is able to login into raspberry but when it comes to line for executing "ls -la" command nothing happens. Can