?
Solved

Bash help for telneting to AS400

Posted on 2009-07-14
1
Medium Priority
?
872 Views
Last Modified: 2013-12-06
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

0
Comment
Question by:yanceyit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
yanceyit earned 0 total points
ID: 24852300
This how-to was found write after i posted my question. The TPUT command i got from google to place a F3 in the script was incorrect. Once I followed the following, the script worked fine. For anyone else having these issues:
 
1.	start od with the -c option 
2.	press the function key 
3.	press the return key 
4.	press ^D 
 
Here's what it looks like when I do that to find out what my F1 key generates:
 
    % od -c
    ^[[11~
    0000000 033   [   1   1   ~  \n
    0000006
    %
 
The string between the 0000000 and \n is what we want. You can translate that into a send command like this one:
 
    send "\033\[11~"

Open in new window

0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question