LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2006, 09:44 AM   #1
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Rep: Reputation: 30
how do i


Im logged in computer A and telnet from A to B, how can I execute a command like ifconfig in computer B and save the output of that command in a file in computer A? is there any way to do that? without ftping of telneting back to computer A?
 
Old 08-22-2006, 10:50 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
telnet B | tee /var/log/telnet.log
 
Old 08-22-2006, 01:35 PM   #3
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
I dont have the tee command
 
Old 08-22-2006, 06:48 PM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
I don't think you can. Telnet was orginally built for dumb terminals to send commands to a server and view the results.
 
Old 08-22-2006, 06:53 PM   #5
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Quote:
Originally Posted by isuck@linux
I dont have the tee command
Maybe that's because your debian is messed up?
You need sh-utils. Try apt-get it or install it from source plz.
edit : after checking, the debian package is named coreutils
#apt-get install coreutils

Last edited by Agrouf; 08-22-2006 at 07:04 PM.
 
Old 08-22-2006, 07:39 PM   #6
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
Code:
ssh user@hostB ifconfig
Will dump the output to your current terminal provided hostB is running an SSH server.
 
Old 08-22-2006, 07:55 PM   #7
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 542

Rep: Reputation: 33
or...
1. startx on A.
2. Open a terminal window on A (vi file to hold ifconfig info)
3. Open another terminal window on A and Telnet or ssh to B
4. do your ifconfig
5. cut and paste it into the vi file from step two.
 
Old 08-22-2006, 10:02 PM   #8
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
No, actually I got it to work with this little piece of bad code.

#!/bin/bash
username=xxx
password=xxx
(sleep 1; echo $username; sleep 1; echo $password; sleep 1; echo "ifconfig ppp0"; sleep 1; echo "exit" |(telnet 192.168.10.1 &>/dev/null)>/tmp/fa.ip
cat /tmp/fa.ip|grep inet | head -1 | awk '/inet[\ ]*/ { print $2; }' | cut -d":" -f2>/tmp/fa.ip

thank you guys for the help.
 
Old 08-23-2006, 11:30 AM   #9
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Cs-cam: As Isuck said on a different thread ([s]he cross-posted this question , e.g., to http://www.linuxquestions.org/questi...php?p=2390748), the other computer is a router of som kind (busybox) and doesn't run an sshd.

Regarding Isuck's refusal of Agrouf's suggestion: You need tee on your local machine NOT on the router. And you should have it; IMO it's a basic UNIX command.

Isuck: Turn to the US government, National Institute of Standards. Seriously, http://expect.nist.gov/ sounds just like what you were looking for:
Quote:
Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial
Run
Code:
autoexpect telnet 192.168.10.1
once, and it will write a script for you. If necessary, you can edit it.

BTW, I think that was an accidental smilie in your 2:02 post today. You can disable them.
 
Old 08-23-2006, 11:28 PM   #10
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
A'right man, thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off




All times are GMT -5. The time now is 02:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration