my expect fils is:
#!/bin/sh
/usr/bin/expect -c 'spawn /usr/bin/ssh root@x.x.x.x "/root/raw/test.sh";expect "password:"; send "pass\n"; interact'
my cron setting for this expect script is
*/2 * * * * bash /home/myuser/myfolder/test.sh
when I run the expect script by using command ./test.sh
in terminal I run ok but doesn't run in crontab
i have to mention i also execute the test.sh by using chmod +x test.sh
what should I do to run the expect script in cron?
2 problems:
there's no executable named " /usr/bin/expect -f /home/myuser/myfolder/test.sh
"
You want to invoke the script with the expect
interpreter, but it's a shell script.
*/2 * * * * bash /home/myuser/myfolder/test.sh
#./usr/bin/expect spawn ssh root@xxxx "/root/raw/test:sh" expect "password:" send "pass\n" interact
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.