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
Tag: expect
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
Unable to mput all the files through sftp in the remote server using expect
I’m trying to mput all files present in the directory : /Test/XML/ into a remote sftp server with the help of expect utility. I’ve around 320 files in the directory: /Test/XML/. The size of each file is around 0.1 MB. There’s no error observed. Here’s my code: But the problem here is, mput * is transferring only 4 files instead
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
SFTP Manual command succeed but script is failing at 1 or 2%
I wrote a script to transfer a folder from VPS to Synology NAS Server. The script fails at 1 or 2% transfer without any indication why. When I run the command manually it works fine without any issues and it transfer the folder flawlessly. I’m not sure what is causing this and would appreciate if i can get some guidance
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
bash command redirection in expect script failing with permission denied (spawn ssh user@host command > outfile)
I have this expect script that is supposed to read a gpg encrypted password, and use it to call a remote script via ssh (there are many reasons why I need to do it like that). Now, my problem is that whenever I run this script, the ssh connection is correctly set up, but it fails in writing the output
When there are multiple “spawn” statements in the expect script, only the last spawn statement is executed fully
From expect script, I am calling two other shell scripts. But only the second shell script seems to get executed properly. Because the output statements of the first shell script is not seen in the screen. This is my expect script: Why is this happening? And what is the fix? Answer You have to wait for the first spawned process
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