shell - BASH scripting for username/password constructs -
i want write simple bash script using ncat open connection isp , port.
the first command be:
nc address port
upon doing this, prompted first provide username. must hit enter, , prompted provide password , must hit enter again.
after this, want open terminal process window. can point me sufficient resources type of scripting?
i know username , password already, i'm not sure how work around fact must provide , hit enter. i'm unsure how open new terminal proceses.
thanks in advance!
check out expect script expect
example:
# assume $remote_server, $my_user_id, $my_password, , $my_command read in earlier # in script. # open telnet session remote server, , wait username prompt. spawn telnet $remote_server expect "username:" # send username, , wait password prompt. send "$my_user_id\r" expect "password:" # send password, , wait shell prompt. send "$my_password\r" expect "%" # send prebuilt command, , wait shell prompt. send "$my_command\r" expect "%" # capture results of command variable. can displayed, or written disk. set results $expect_out(buffer) # exit telnet session, , wait special end-of-file character. send "exit\r" expect eof
Comments
Post a Comment