« 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
 
(2 versions intermédiaires par le même utilisateur non affichées)
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]]
‎<html>
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
  kofiWidgetOverlay.draw('yakakliker', {
    'type': 'floating-chat',
    'floating-chat.donateButton.text': 'Café',
    'floating-chat.donateButton.background-color': '#00b9fe',
    'floating-chat.donateButton.text-color': '#fff'
  });
</script>
‎</html>
‎<html>
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a>
‎</html>

Dernière version du 17 février 2025 à 17:56

#!/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

Lien

https://phoenixnap.com/kb/linux-expect


compteur web gratuit sans pub