Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Telent problem (and other commands)

Status
Not open for further replies.

martinfortmann

Programmer
Mar 25, 2003
5
AU
Hi

We are moving from an old HPUX box to a new AIX box and are having a few problems with standard UNIX utilities on the AIX box.

Firstly telnet.

We have a script with the following code

telnet $Host 80 <<-EOF > $WebPageFile 2>$TelnetError
GET
EOF

The result in $WebPageFile is:

Trying...
Connected to 10.13.200.33.
Escape character is '^]'.
Connection closed.

What is expected is:

Trying...
Connected to 10.13.200.33.
Escape character is '^]'.
get HTTP/1.0 401 access denied
Basic realm=&quot;WebIntelligence (14:00:52 Mar 26 2003)&quot;
Set-Cookie: WebIntelligenceSession=EN572529E4QT17; path=/wi
status: 401
Content-Length: 115

<HTML><HEADER><TITLE>WebIntelligence</TITLE></HEADER><BODY onLoad='location=&quot;/wi/&quot;;' bgcolor=white>
</BODY></HTML>Connection closed.


Why will the output not appear. The problem is repeatable from the command line. However, if I enter telnet $Host 80 at the prompt and then manually enter the Get command, the result is as expected. Any suggestions, please.

The other problem was with &quot;time&quot; but I suspect this may be a problem with other commands. What I was trying to do is send the output of &quot;time&quot; to a file, eg.

[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>time ls 2> myfile
avg_mem.sql free_space.sql longprog.sql sgachk.sql tr_r_f_update.sql
bindvals.sql hitratio.sql mincache.sql sqlcache.sql utlxplan.sql
buffercache.sql index_extents.sql monses.sql sw.sql what_sql.sql
cleanplan.sql indx.sql myfile sw2.sql xplain.sql
delplan.sql iobottle.sql no_space.sql tblsps.sql
disk_read.sql lock1.sql plsql_cache.sql test.sql
expplan.sql lock_user.sql readplan1.sql tmp.sql

real 0m0.01s
user 0m0.00s
sys 0m0.00s
[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>cat myfile
[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>

As you can see, myfile is empty while the &quot;time&quot; output is on the screen. If, however, I enter the full path to &quot;time&quot; the result is as expected

[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>/usr/bin/time ls 2> myfile
avg_mem.sql free_space.sql longprog.sql sgachk.sql tr_r_f_update.sql
bindvals.sql hitratio.sql mincache.sql sqlcache.sql utlxplan.sql
buffercache.sql index_extents.sql monses.sql sw.sql what_sql.sql
cleanplan.sql indx.sql myfile sw2.sql xplain.sql
delplan.sql iobottle.sql no_space.sql tblsps.sql
disk_read.sql lock1.sql plsql_cache.sql test.sql
expplan.sql lock_user.sql readplan1.sql tmp.sql
[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>cat myfile

Real 0.00
User 0.00
System 0.00
[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01/debug>

Has anyone come across these problems and how did you over come them?

Many thanks
Martin
 
Worked out the &quot;time&quot; problem. There is a built in &quot;time&quot; function in ksh which works differently from /usr/bin/time. So, if you want to redirect the std err then you have to specify the path to use the correct &quot;time&quot;.

Now, if I could only figure out the telnet probelm!!!!!
 
I don't think the AIX telnet accepts here documents in the same way that ftp does.
I've always done this kind of thing using expect/tcl, but other options are:
1) use the kermit telnet which comes with scripting support.
2) use the perl net::telnet module.
3) rewrite your scripts to use a coprocess (only for the seriously wierd amongst us).
 
I think AIX telnet does accept here documents. Here is the same command entered manually at the prompt ...



[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01>telnet 10.13.200.33 80
Trying...
Connected to 10.13.200.33.
Escape character is '^]'.
GET HTTP/1.0 401 access denied
Basic realm=&quot;WebIntelligence (09:16:43 Mar 28 2003)&quot;
Set-Cookie: WebIntelligenceSession=EN57278A4BQT2; path=/wi
status: 401
Content-Length: 115

<HTML><HEADER><TITLE>WebIntelligence</TITLE></HEADER><BODY onLoad='location=&quot;/wi/&quot;;' bgcolor=white>
</BODY></HTML>Connection closed.
[dmld01@amppsdmd1]DRIDMSPT:/home/dmld01>



So it does appear to accept the here document, just not where it's in a script!?!?!?!?!?!?!?!?!
 
martinfortmann - We appear to have a difference of opinion over terminology.

To me the here document is defined by the script, ie the code between << EOF and the EOF line whatever that code may be.

 
Hmmm, sectorseveng, not a difference of opinion - just that you know what you're talking about and I, well, don't *BLUSH*

Anyway, it appears that the telnet seems to execute whats in the here document (now that I know what that is *blush*) but just does not return any output. Most annoying.

Many thanks for the help in anycase. Some one here wrote a perl pseudo telnet using the socket library that gives us the output we expect.

Thanks again
Seeya
Martin
 
Have found the solution. There is a -e flag under AIX telnet which overrides terminal-type negotiation. The session I had open was vt220 emulation. Using telnet -e vt100 made std out &quot;visible&quot;.

Just thought I'd let you know. Still surprised that it works when entered manually from the keyboard but not the here document.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top