Skip to main content

Tip. Automate Text Input in Commands

Jose CerrejonLess than 1 minuteAppleLinuxRaspberry PIAppleLinuxRaspberry PI

Tip: Automate Text Input in Commands


Sometimes it can be tedious to enter certain data in the command line, especially if you have to repeat it several times.

Imagine ftp command line authentication. We can make use of the expect command...

Those of us who use *Axway Appcelerator titanium_ sometimes have to logout/login every time we change from one computer to another and validate the license again. Now anymore!. It will be easier if you modify and execute the following script according to your needs:

spawn appc logout
expect eof
spawn appc login
    set timeout 2
    expect "? Appcelerator ID:"
    send "\r"
    expect "? Password:"
    send "your_password\r"
expect eof

You have to change and your_password.

You can use with other commands: ftp, ssh, etc...

Link: expect (man)open in new window

Link: > 6 Expect Script Examples to Expect the Unexpected (With Hello World)open in new window