F
F
frizesb2018-11-23 15:22:43
bash
frizesb, 2018-11-23 15:22:43

Can you help me with EXPECT?

Guys help me make the if then else loops correctly so that I can check expect

expect -c "
set timeout 120
spawn scp -r /home/administrator/crontab/ [email protected]$H:/home/administrator
expect password ;
send \"$password\n\" ;
expect \"scp>\""
then echo "OK" ; else echo "NO"; fi
if
expect -c "
set timeout 1 
spawn ssh [email protected]$H;
expect password ;
send \"$password\n\" ;
expect *> ;
send \"sudo mkdir /home/user/.cron\n\" ;
expect password ;
send \"$password\n\" ;
expect *> ;
send \"sudo cp -f -rp /home/administrator/crontab/crontab/del.sh /home/user/.cron\n\" ;
expect *> ;
send \"sudo crontab -u user /home/administrator/crontab/crontab/reg\n\" ;
expect *> ;
send \"sudo rm -rf /home/administrator/crontab\n\" ;
expect \"ssh>\""

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2018-11-23
@saboteur_kiev

Why do you need expec?
Set up SSH keys and just go without entering a password

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question