All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
0answers
26 views

how to send special characters in expect script?

I'm trying to send special characters (password) which contains #?!k;|C . these password is dynamic and cannot be hardcoded in script. so I'm passing through variable as below $ expect ./...
0
votes
1answer
60 views

Control a bash instance by a script (in a robust way)

I'd like to control some bash programs (local, or ssh) with some (eventually interactive) scripts (say python) in a robust way. I'd like to send commands, get the stdout/stderr of that command at the ...
0
votes
0answers
28 views

How to switch user in the server by su without password through shell script?

I am using cygwin to run my expect command for login into server. Once login i have to switch the user by su command writing password in the shell script which does not prompt for password and ...
0
votes
1answer
102 views

Commands leaking characters to bash

While building a small expect script I noticed that, after executing the script, some characters were automatically on the input of bash. I have seen that on other programs before, but here I have ...
1
vote
2answers
194 views

How can I “source” expect script

I'm forced to use a script like below: # test.sh function my_fun { echo "Give value for FOO" local my_var read my_var export FOO=$my_var } # Call my_fun function my_fun by sourcing ...
0
votes
1answer
63 views

How to execute command under if statement in Shell Script under expect condition?

send "if [ `ps -ef | grep ttyS1 | sed -n 1p | cut -d ' ' -f 2` -eq 'ttyS1' ]; then not_found='false' else not_found='true' fi\r" I have tried so many time with double quote and single quote also ...
1
vote
2answers
143 views

Automate variable number of inputs in for script

I understand these 3 options for automating an interactive script: Pipe answers to executable eg. yes '\n\n\n\n\nY\n' | ./script yes command to pass the same reply to all questions expect to provide ...
4
votes
1answer
426 views

Pass variable to spawn [duplicate]

I want to pass server name which is listed in a file (servers_list) as variable to spawn command which is in another script (user_create_script). Purpose of this script is to create user(david) in ...
1
vote
0answers
232 views

Create new file after `scp` in remote script [closed]

Learning bash and trying to copy a file from a local machine to a remote machine. I would like to create a simple .txt file on the local machine that logs a success. This is my first foray into bash, ...
0
votes
2answers
66 views

answering command automatically - performing cp operation between answers [closed]

The idea is that I want to execute a command, then it asks for a file name to process, and after it is done with processing, it outputs an image with the name prediction.png, it asks for the next ...
0
votes
1answer
446 views

Unix shell script using Expect shell

Im writing a script to collect micro code levels for adapters on each servers in AIX, using Expect shell. #!/bin/ksh for hostname in ABCD123 ABCD234 ABCD445 do expect << 'EOS' set hos {$...
1
vote
1answer
3k views

How to pass parameters to EXPECT using the '-c' option?

I'm using expect inside my bash script by using expect -c, but how do I pass parameters to it? This is what I've tried: FILE="myFile" HOST="myhostname" /usr/bin/expect -c $FILE $HOST ' set ...
0
votes
1answer
577 views

Passing parameters by shell script file to expect script

I need to pass a paramter from a shell script under command line of ssh script for example : #!/usr/bin/expect spawn ssh user@servername.com "cm1+passingparameters.sh;cmd2" my existing script 123....
0
votes
1answer
1k views

Using expect to execute remote script and get script exit status

I have a script which is on remote server which returns exit status of the script. Now I want to execute that remote script using expect and get the exit status of the script. My remote server script ...
1
vote
1answer
98 views

Run a command based on stdout frequency

I have a program that writes to stdout in a batch of text very quickly, but the output doesn't have a specific output that I can write an expect loop for. Example of stdout of my program: [time:here] ...
0
votes
2answers
2k views

Expect script fails when running from cron but works when run manually

I have a script in Linux that creates a file which once created it executes an Expect script that uploads the created file to an SFTP server. I have this running in cron and for whatever reason the ...
1
vote
1answer
5k views

Spawn command not found

I trying to use the spawn command to connect to remote server, execute some commands/script. Here is script: #!/usr/bin/expect for i in `srvctl status database -d PROD | awk -F " " '{print $(NF)}'` ...
1
vote
1answer
1k views

Send command to already running process in shell script

In bash how can I issue a command to a running process I just started? For example; # Start Bluez gatttool then Connect to bluetooth device gatttool -b $MAC -I connect # send 'connect' to the ...
0
votes
2answers
10k views

Unable to execute bash script inside expect script

i have a expect script like #!/usr/bin/expect ..... spawn passwd expect "password:" send "password" .... .... .... ~/test.sh Wile executing this, I'm unable to run bash script test.sh. How to ...
0
votes
2answers
900 views

Can I have a (bash) shell with expect running in the background?

I am trying to write an expect script that once started will watch my terminal and run a command every time that it finds a match. Is this even possible with expect? If so, would expect_background ...
1
vote
0answers
294 views

Start a subshell then run commands

Say I have a script that is always run from an interactive shell. I would like this script to launch an interactive subshell that is a replica of the parent (i.e., all environment variables, etc. ...
1
vote
1answer
2k views

Get only files modified within last 30 minutes using sftp get

Within a .sh script, I'm using expect to automatically sftp to another computer in order to get files. My script will be set to run every 30 minutes, at which point I want to get only files that were ...
5
votes
2answers
5k views

scp command behaves differently when used with expect utility

expect -c 'spawn scp -C -o CompressionLevel=9 ~/partFiles/* abc@10.200.4.15:/export/home/abc/; sleep 10; expect password; send "secretPassword\n";interact' throws - ~/partFiles/*: No such file or ...
0
votes
1answer
2k views

Use a script for a telnet session

I have a problem with my script. It seems my password is wrong. #!/usr/bin/expect set ip [lindex $argv 0] spawn telnet $ip set timeout 10 expect "Login:" send "administrator\r" expect "Password:" ...
1
vote
2answers
3k views

Understanding echo/spawn/send/expect construct

Here is a line from a bash script I am trying to understand: echo "spawn myscript.sh arg1 arg2; expect \"Please enter your value: \"; send \"myval\r\"; expect eof" | expect I think I understand the ...
3
votes
3answers
6k views

Pass the background flag (&) through expect and ssh

My command line/bash fu is extremely weak, but I'm trying to hone my abilities. Hopefully someone can help. I wrote a super simple expect script so that I can SSH in to a headless box we're using at ...