expect

Executing a bash script in python

风流意气都作罢 提交于 2019-12-07 20:58:41
问题 I've created an expect script that, when executed, ssh's onto a server and executes a series of commands. Pseudocode looks like this: #!/usr/bin/expect spawn ssh usr@myip expect "password:" send "mypassword\n"; send "./mycommand1\r" send "./mycommand2\r" interact When executed from a bash shell ($ ./myscript.txt) the code executes fine. What I would now like to do is have a line in python file that runs the commands in the script the same way the bash shell does. Pseudocode looks like this:

Trouble logging in user using su and expect script

北城以北 提交于 2019-12-07 17:25:11
问题 I am working on making a website for a class that you log into with a username and password, and then it takes you to a page that shows your grades in the class. The website is being run with a bash script, and will be hosted on a machine where the users already have a username and password to login. I also have a script called calcgrade.sh that will calculate the grades for either the user who is currently logged in, or the user passed to the script as an argument. So originally, I was going

How to cross compile Expect for ARM

北城余情 提交于 2019-12-07 14:32:40
问题 How does one cross-compile Expect for ARM? It is absolutely no problem to build it from source on a host Ubuntu machine. But if you try to cross compile it, the configure script constantly gives the following error: checking if WNOHANG requires _POSIX_SOURCE... configure: error: Expect can't be cross compiled There seems to be someone who found out how to do it here (but he doesn't elaborate): https://linuxlink.timesys.com/cross_compiling_expect I also took the source and patches from here:

Catching a dying process in pexpect

折月煮酒 提交于 2019-12-07 13:14:17
问题 I'm writing some pexpect stuff that's basically sending commands over telnet. But, it's possible that my telnet session could die (due to networking problems, a cable getting pulled, whatnot). How do I initialize a telnet session such that, if it dies, I can catch it and tell it to reconnect and then continue execution of the code where it was at. Is this possible? 回答1: IMHO, you're normally better-off with a currently-maintained library like exscript or telnetlib, but the efficient

expect utility is not working when executing from jenkins

陌路散爱 提交于 2019-12-07 01:32:53
问题 we have a unix script which uses expect utility for interactive execution. This script works well when we run from unix server. If we run this script from Jenkins, it is not working. Below is the script var="xxxxx" expect -c " spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins expect { "Password:" { send $var\r;interact } } exit " Below is the output when we run from jenkins spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins Password: Password

TCL_REGEXP::How to grep words from tcl variable and put into a text file, seperated with comma?

匆匆过客 提交于 2019-12-06 17:33:33
问题 set line { Jul 24 21:06:40 2014: %AUTH-6-INFO: login[1765]: user 'admin' on 'pts/1' logged Jul 24 21:05:15 2014: %DATAPLANE-5-: Unrecognized HTTP URL www.58.net. Flow: 0x2 Jul 24 21:04:39 2014: %DATAPLANE-5-: Unrecognized HTTP URL static.58.com. Flow: Jul 24 21:04:38 2014: %DATAPLANE-5-: Unrecognized HTTP URL www.google-analytics.com. Flow: 0x2265394048. Jul 24 21:04:36 2014: %DATAPLANE-5-: Unrecognized HTTP URL track.58.co.in. Flow: 0 Jul 24 21:04:38 2014: %DATAPLANE-5-:Unrecognized HTTP URL

top command in shell script

耗尽温柔 提交于 2019-12-06 16:00:18
I am trying to get first 5 lines of top command through expect script. Im calling this expect script from a shell script along with some other stuff. top | head -5 gives me below output ie without cpu stats- top - 09:10:58 up 46 days, 17:03, 12 users, load average: 0.01, 0.02, 0.00 Tasks: 138 total, 1 running, 137 sleeping, 0 stopped, 0 zombie Mem: 16432400k total, 8408096k used, 8024304k free, 609200k buffers Swap: 6290736k total, 0k used, 6290736k free, 6754356k cached If I run just top command on that remote server I can see there is a 2-3 second delay before the CPU states line is updated,

Execute remote commands from Debian to Windows via Telnet

社会主义新天地 提交于 2019-12-06 15:01:30
问题 I am working on remotely executing a command line in Windows from Debian. For that, I tried to use the bash script below. Using the expect tool, it consists in connecting via telnet to the remote server, entering username and password values and sending the command line desired. #!/usr/bin/expect set timeout 20 set name 192.168.1.46 set user Administrateur set password MSapp/*2013 set cmd "TASKKILL /F /IM Tomcat6.exe" spawn telnet 192.168.1.46 expect "login:" send "$user\r" expect "password:"

how to hide ssh expect user/password

无人久伴 提交于 2019-12-06 14:37:41
问题 My Expect script shows password/user in clear text and I want to hide it. #!/usr/local/bin/expect ########################################################################################### ############ # Input: It will handle two arguments -> a device and a show command. ########################################################################################### ############ # ######### Start of Script ###################### # #### Set up Timeouts - Debugging Variables log_user 0 set timeout

How do I use expect to connect via ssh to a system and change the password of the host system?

别等时光非礼了梦想. 提交于 2019-12-06 11:23:20
问题 I am automating the process of: Connect to a system named "alpha" via ssh with password "alpha" for username "alpha". Once connected I would like to set the root password (to "kickass"). The system I am connecting to doesn't have a root password by default. I wrote this expect script to do the job but it doesn't work consistently. It works once and then if I change the password to test again, it waits at the "Enter new UNIX password:" prompt after issuing "sudo passwd root". Any ideas? #!/usr