Sponsored Content
Full Discussion: Telnet Session
Top Forums Shell Programming and Scripting Telnet Session Post 68704 by Perderabo on Wednesday 6th of April 2005 10:41:09 AM
Old 04-06-2005
You could use expect, a bit like this. What you're trying to do is hard. In place of your
echo "exit"
you will need a loop that reads from stdin and writes to the telnet process. The next problem is terminated that loop and the remote shell at once. In the code below, I went with cntl-d. When the user types EOF (usually cntl-d), the loop terminates. Then the remote shell is sent an "exit". You can only send lines to the remote shell this way. No vi. No emacs. So I agree with No Ice, rch or ssh is the way to go. Still here is my code....

Code:
#! /usr/bin/ksh
HOST=xxxxxx
USER=yyyyy
PASSWD=zzzz

exec 4>&1
telnet  >&4 2>&4 |&

print -p open $HOST
sleep 3
print -p $USER
sleep 3
print -p $PASSWD
sleep 3
print -p df -k
sleep 3
while IFS="" read line ; do
        print -p "$line"
done
print -p exit

wait
exit 0

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

telnet session timeout

hi, we can set something such that if the user has been idle for a while, it will auto disconnect. where to do so? thanks (6 Replies)
Discussion started by: yls177
6 Replies

2. Shell Programming and Scripting

Telnet session does not expire

Dear friends.. Our project has a module that runs on handheld devices. Through the handheld we telnet to solaris where the application actually runs. I noticed that after starting a session through the handheld, if i go out of range or if i remove and replace the battery in the handheld, the... (1 Reply)
Discussion started by: deepsteptom
1 Replies

3. UNIX for Dummies Questions & Answers

check for successfull telnet session

In either case using ksh or tcl, how can I check that I have a successfule telnet session and am being prompted with a tacacs login prompt ? :confused: DOIT () { sleep 2 echo "<tacacs name >" sleep 1 echo "<password>" echo "en" sleep 1 echo "<enable password>" echo "term length 512"... (0 Replies)
Discussion started by: sumguy
0 Replies

4. UNIX for Dummies Questions & Answers

Unix Telnet session

Hi Is there any way whilst in a telnet session you can view your client machine name that you are using to connect to the Unix box ? :eek: (2 Replies)
Discussion started by: mlucas
2 Replies

5. UNIX for Dummies Questions & Answers

Telnet Session to AIX

Hello, I have AIX 5.3 at home connected to netgear router. Port Forwarding has been enabled on the router. Problem is that if I want to telnet, I have to try 2 or 3 times before I can get a logon prompt. It times out for first or second time (Connection to session <IP_Address> failed: Connection... (1 Reply)
Discussion started by: bluebee
1 Replies

6. UNIX for Dummies Questions & Answers

Disconnecting a telnet session

How can I disconnect an existing telnet session? The host is a serial port server with multiple ports. The users login using the host's name and a port, i.e. telnet host01 1235. Thanks. (14 Replies)
Discussion started by: cooldude
14 Replies

7. UNIX for Dummies Questions & Answers

Pls recommend a telnet session

hi guys, currently i'm using putty and hyper terminal in my telnet session mostly on hp servers. problem is when im trying to use putty to connect with the mp console im unable to connect because im using a usb-to-serial cable & putty only configured to com1. reason for this is i want to save... (2 Replies)
Discussion started by: gob23g
2 Replies

8. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

9. SCO

Telnet session disconnects abruptly

I have inherited and SCO OpenServer Release 6 server. The clients connect using telnet to get to a proprietary database application for Service tickets. The issue I am currently having is that the connection just stops abruptly and you can see "telnet session terminated" on the terminal emulation... (22 Replies)
Discussion started by: sean6605
22 Replies
ZSSH(1) 							       ZSSH								   ZSSH(1)

NAME
zssh - interactive file transfer wrapper for ssh SYNOPSIS
zssh [zssh options] [--] [ssh options] ztelnet [zssh options] [--] [telnet options] DESCRIPTION
zssh (Zmodem SSH) is a program for interactively transferring files to a remote machine while using the secure shell ( ssh ). It is intended to be a convenient alternative to scp , allowing to transfer files without having to open another session and re-authenticate one- self. zssh is an interactive wrapper for ssh used to switch the ssh connection between the remote shell and file transfers. This is achieved by using another tty/pty pair between the user and the local ssh process to plug either the user's tty (remote shell mode) or another process (file transfer mode) on the ssh connection. ztelnet behaves similarly to zssh, except telnet is used instead of ssh. It is equivalent to 'zssh -s "telnet -8 -E"' Files are transferred through the zmodem protocol, using the rz and sz commands. zssh behaves as an usual ssh session until the escape sequence is depressed ( default is ^@ which can be produced by pressing C-space, or C-2, or C-` ), which enables file transfer mode. A new prompt is then displayed, and commands can be executed locally to initiate file transfers (among other things). It roughly behaves as a local shell featuring line edition, history and completion (thanks to libreadline), globbing, and escape characters ( " ' and ). The following builtins are handled by zssh itself: ? , cd , disconnect , escape , exit , help , hook , quit , repeat , rz , suspend , sz , version cd <dir> change current directory disconnect disconnect and exit escape [^X] Change escape key to ^X. Without argument, print current escape key exit exit file transfer mode. ^D may also be used for this purpose. help print help and tips ? hook prg [args] Hook program 'prg' on the the pty. Its standard input and output will go through the ssh channel. typing 'sz'/'rz' is in fact equivalent to 'hook sz'/'hook rz' A weird imagination is most useful to gain full advantage of this feature. quit same as exit. repeat repeats cmd forever (^C to interrupt). Useful for example if you use a remote script invoking "sz" and you don't want to be typing "rz" each time... Remember however that several files can be transferred by a single sz/rz pair so this is not usually necessary to use repeat. rz Receive files from the remote machine. runs rz and plugs the process on the ssh connection. running sz on the REMOTE machine is required : 1) run `sz <remote_file> ...' from the remote machine shell 2) press the escape sequence (C-space) to enter file transfer mode 3) run the `rz' builtin suspend suspend zssh (back to the local machine shell) sz <file> ... Send files to the remote machine. runs sz and plugs the process on the ssh connection. There is no need to manually run rz on the remote side. version print version information builtins rz , sz , hook and exit return to shell mode after completion. OPTIONS
-f --force Do not ask user any question -h --help show basic help -s cmd --shell cmd run cmd as remote shell instead of the default "ssh -e none" (zssh) or "telnet -8 -E" (ztelnet) ex: zssh -s "rsh -x" -V --version show version -z ^X --zssh-escape ^X set escape sequence to ^X -- may be used to separate zssh options from ssh ones Other arguments are passed verbatim to ssh/telnet/whatever. ENVIRONMENT
ZSSHESCAPE Setting the ZSSHESCAPE environment variable allows to override the default escape sequence. ZSSHESCAPE should contain only two characters of the form `^X', meaning that ^X is to be the new escape sequence. REQUIREMENTS
the following binaries need to be properly installed for zssh to work : ssh/telnet/... the remote shell to be executed (local machine) sz rz zmodem send and receive programs. Should be both on local and remote machine, and (hopefully) of compatible versions. TIPS
If file transfer is initiated but never completes ( ie a line like : Bytes Sent: 38144/4610624 BPS:3424 ETA 22:15 or Bytes Sent: 0/ 513 BPS:0 ETA 00:00 Retry 0: Got ZCAN can be seen, but transfer never completes ) Chances are the pty/tty on one of the systems are not 8-bit clean. (Linux is 8-bit clean, NetBSD is not). Using the -e (escape) option of rz should solve this problem. Transfers can be interrupted with ^C (somewhat experimental =) If you get stuck in rz/sz (for example you've just ran rz, but you then decided not to transmit anything), hit a dozen ^X (Ctrl-X, not the zssh escape!) to stop it Use `sz -y <files>' to overwrite files on the other side BUGS
/ LIMITATIONS You may sometimes have to hit return 2 or 3 times after file transfer completion in order get back to the shell. Some digits are usually displayed; don't worry it won't harm (you or your term) ... the tty may (sometimes) be somewhat upset after an interrupted transfer ( using ^C ). typing `reset' in this case should help. no pipe, redirection (and other stuff) support in shell ... but after all there are already wonderful shells around =) CREDITS
ttssh's author - Robert O'Callahan - for the original idea The sourceforge team. AUTHOR
Matthieu Lucotte <gounter@users.sourceforge.net> zssh homepage: http://zssh.sourceforge.net SEE ALSO
ssh(1), telnet(1), scp(1), sz(1), rz(1), readline(3), ZSSH
June 26, 2000 ZSSH(1)
All times are GMT -4. The time now is 04:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy