« Linux : Script avec expect » : différence entre les versions
De www.yakakliker.org
(Page créée avec « <syntaxhighlight lang="bash"> #!/usr/bin/expect set timeout 20 set ip [lindex $argv 0] set user [lindex $argv 1] set password [lindex $argv 2] spawn ssh -o "StrictHostKeyChecking no" "$user\@$ip" expect "password:" send "$password\r"; expect "# " send "apt-get update\r" expect "# " send "apt-get upgrade -y && exit\r" expect "# " send "ls\r" expect "# " send -- "\r" send "exit\r" expect "# " send "exit\r" interact #expect eof </syntaxhighlight> [... ») |
Aucun résumé des modifications |
||
Ligne 39 : | Ligne 39 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Lien === | |||
https://phoenixnap.com/kb/linux-expect | |||
[[Catégorie:Linux]] | [[Catégorie:Linux]] | ||
[[Catégorie:Scripts]] | [[Catégorie:Scripts]] | ||
[[Catégorie:Expect]] | [[Catégorie:Expect]] |
Version du 22 avril 2024 à 09:38
#!/usr/bin/expect
set timeout 20
set ip [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
spawn ssh -o "StrictHostKeyChecking no" "$user\@$ip"
expect "password:"
send "$password\r";
expect "# "
send "apt-get update\r"
expect "# "
send "apt-get upgrade -y && exit\r"
expect "# "
send "ls\r"
expect "# "
send -- "\r"
send "exit\r"
expect "# "
send "exit\r"
interact
#expect eof