Link to home
Start Free TrialLog in
Avatar of yanceyit
yanceyitFlag for United States of America

asked on

Bash help for telneting to AS400

Trying to automate a program that needs to be ran on our AS400. The script is fairly bland and simple, yet i cannot get it to work completely. It logs in just fine, but needs to run one step prior to calling the PGM. I've searched for other answers to this but i cant seem to get them to work correctly. The steps are as follows:

telnet as400
login
password
F3
CALL PGM(program)
SIGNOFF

The code I am using is below. This is my first question so I am not too sure what other information anyone would need. In my script i DID have variables used for $user and $pass but had issues logging in, so using (send "username") seemed to atleast get me logged into the system.

The script fails on the F3 command. I am not too familiar with the tput command. Are there other options? When the script fails to send a 'F3', it tries to send the CALL PGM instead and then it fails sending me back to my prompt.

Thanks in advance.
#!/bin/bash
/usr/bin/expect -  << END
spawn /usr/bin/telnet 192.168.100.1
expect "User*"
send "username"
send "\t"
send "pass"
send "\r"
sleep 5
exec tput kf3
send "CALL PGM(program)\n"
send "SIGNOFF\n"
expect eof
END

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of yanceyit
yanceyit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial