Skip to content
Advertisement

Tag: expect

Error using expect to execute shell script

I am using an expect script to automatically answer prompts in a shell script designed to add Linux systems to active directory. I only have three prompts: location, username, password. I am using Ansible to execute it. The issue when the script executes, it tries to install ~ 49 rpms on the vm, adcli, realmd, etc. Yum begins install the

issue in logging in as sudo user

here is the script sample.expect : expecting to log into the host as sudo user. but getting issue [sudo] password for USER: invalid command name “sudo” while executing “sudo” invoked from within “expect “[sudo] password for USER:”” (file “sample.expect” line 6). Answer That uses square brackets, which are Tcl’s mechanism for command substitition. You have to either escape the leading

Expect: How to iterate over files in a directory?

The following is a bash script which iterate over .csv files within a directory. The question is, I now have an expect script #!/usr/bin/expect where I want to use the same for loop. How could I achieve that? Answer You would write: Expect is an extension of Tcl. In addition to the expect man page, a link to the Tcl

Linux shell: my `expect` script doesn’t work as expected

I’ve got a simple script like below, read 2 numbers from command line and add them together: It runs, no problem. Then I wrote an expect script like below: Seems still it prompts to read from command line, after quite a long time, it ends. Where did I get wrong? Thanks. Answer You have to send the newlines as well,

Linux expect command without interact directive not working

I want to login from 192.168.119.128 to 192.168.119.129 automatic and run some commands, so I write an expect script. a.sh The output is: I login successfuly, but it seems touch /tmp/a.txt command is not run. When I uncomment the last line #interact of a.sh, it works, and the file a.txt is created. Here is the output: Why without the interact

Expect script on linux

I would like to make a expect script which can answer the question by using srand functuon. For example, I will use netcat to connect to the server, and I will get a question from server like “please enter 0 or 1”; then I hope my script can answer the question automatically by using the code like above. If you

Advertisement