How to check if telnet works?

  • Permalink
  • submit to reddit
  • Email
  • Follow


I would like to check programmatically if I can telnet to a Unix box
without errors.

I know an extensive solution would require Expect for analyzing output
but
I am looking for something simple.

0
Reply SQ 8/18/2006 9:23:23 PM

See related articles to this posting


2006-08-18, 14:23(-07), SQ:
> I would like to check programmatically if I can telnet to a Unix box
> without errors.
>
> I know an extensive solution would require Expect for analyzing output
> but
> I am looking for something simple.

If you want to verify that you can login with your user and
passwd, then you'll need something like expect.

if 
  HOST=machine USER=me PASS=pass expect -c '
    spawn telnet $env(HOST)
    expect_after timeout {exit 1} eof {exit 1}
    expect {
      "ogin:" {
	send "$env(USER)\r"
	expect assword: {send "$env(PASS)\r"}
      }
      assword: {send "$env(PASS)\r"}
    }
    expect -re {[$#>] }' > /dev/null 2>&1
then
  echo I could login to that machine
fi

Alternatively, you can do:

{
  {
    sleep 5
    echo me
    sleep 2
    echo pass
    sleep 10
  } | telnet machine 2>&1
  echo
} | grep -q '[$#>] '

But that would be less reliable

-- 
St�phane
0
Reply Stephane 8/19/2006 10:15:32 AM
comp.unix.shell 15063 articles. 25 followers. Post

1 Replies
349 Views

Similar Articles

[PageSpeed] 24


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Check Internet Connection
Hi, I have this code in Access 2003 for checking if an Internet connection is present: (In the code below, "somedomain" represents the web site that is used to check for the update. I have substituted other domains in to test it.) ********************************************************* Private Const FLAG_ICC_FORCE_CONNECTION = &H1 Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" _ (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long Code in the Form_Load Event: If Internet...

checking telnet?
Is there someplace you can telnet to to check if your telnet is working properly? Say you can't connect to your favorite site and wonder if it's you or them. -- Ron Hardin rhhardin@mindspring.com On the internet, nobody knows you're a jerk. ...

telnet via PuTTY hangs, Windows-builtin telnet works
Hello *, Whenever I start a telnet session via PuTTY to my local SMC Barricade Router, it hangs after a random time (no matter if idle or in use). Same thing via telnet from commandline prompt works without problems. Can anyone tell me which settings have to be changed in PuTTY? Best Regards, Andreas. ...

telnet localhost 25 works, telnet servername 25 connection refused
Using Solaris 10 (x86) with Sendmail 8.14.4, I am logged into the machine as root. Basically, I can telnet to port 25 of localhost but not of the machine name or the IP address. # telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 <servername> ESMTP Sendmail 8.14.4/8.14.4; Thu, 22 Jul 2010 14:43:06 -0500 (CDT) # telnet <servername> 25 Trying <ip address>... telnet: Unable to connect to remote host: Connection refused ----- /etc/hosts contains 127.0.0.1 localhost <ip address> servername servername.duc.aubur...

URGENT HELP - form submit stops working when so many check boxes checked
Hi there, A PHP application I built has a section which lists a number of members to a club whose names each appear with a check box beside them that can be ticked. These check boxes are part of a form which amongst other submit buttons has a one particular submit button that if checked will send the form data (using GET) to a script that will email all the checked members. The client today phoned to say that when the check a few members on the form (only about 10 actually) and pressed the submit button it done nothing (In fact all submit buttons on form stop working). A can verify th...

ssh tunnel // "telnet localhost tunnel_port" works, from remote host "telnet hostname tunnel_port" fails
Hi Guys, I got a SUSE linux box with OpenSSh installed. <hostname>:/proc # uname -r 2.4.21-138-smp <hostname>:/proc # ssh -Version OpenSSH_3.4p1, SSH protocols 1.5/2.0, OpenSSL 0x0090607f I use "ssh <remotehost_1> -L 54321:<remotehost_2>:23 to build a ssh tunnel for a telnet session to remotehost_2 (which can not be accessed from my linux box directly). remotehost_2 is a HPUX box, could be anything else too When I use "telnet localhost 54321" on my linux box this works fine When I use "telnet <hostname> 54321" on my linux box it fails ...

ssh tunnel // "telnet localhost tunnel_port" works, from remote host "telnet hostname tunnel_port" fails #2
Hi Guys, I got a SUSE linux box with OpenSSh installed. <hostname>:/proc # uname -r 2.4.21-138-smp <hostname>:/proc # ssh -Version OpenSSH_3.4p1, SSH protocols 1.5/2.0, OpenSSL 0x0090607f I use "ssh <remotehost_1> -L 54321:<remotehost_2>:23 to build a ssh tunnel for a telnet session to remotehost_2 (which can not be accessed from my linux box directly). remotehost_2 is a HPUX box, could be anything else too When I use "telnet localhost 54321" on my linux box this works fine When I use "telnet <hostname> 54321" on my linux box it fails ...

automating telnet and checking
i need a help in scripting. i need to check the systemhealth ( disk free) in all the servers daily. suppose iam on a system: local : remote1 ,remote2.... the script is for telneting the each remote system using same username(user), password (user) and execute the command # df -h and direct the output of this to local/syshealth if you want to use telnet then you're going to have to use a program such as expect to pass in the password. It would be far easier to use ssh and setup public private key exchange. rajkiran wrote: > i need a help in scripting. > i need to ...

Works in telnet but not in perl?
I have a perl program that is converting a pdf file to a jpg using imagemagik and gs. Using the following command line in a telnet shell logged in as the webmaster and in the same directory as the perl program it works: cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf - resize 300 ZGRH3122CHAP070827063618-1-1.jpg But when I do it in perl with the following: system("cd $displaypath;/usr/local/bin/convert $THISPROJECT $thepagemap[$i].pdf -resize 300 $THISPROJECT$thepagemap[$i].jpg"); which expands out to (same as above): cd Pages;/usr/local/bin/convert ZGRH3122CHAP...

Checking that microphone is working
I have some issues that are a little complicated to explain. As part of troubleshooting this, I want to make sure that the microphone is working, that it can capture sound and sound can be recorded to a file. So. What sort of command can I use to record a few seconds of sound from a microphone into a file, mp3 or .wav or whatever, that I could later play with mplayer. Thanks. Also, I am totally lost in sound settings. I have two sound cards, one built into the mobo and one Sound Blaster Live. I have no idea how to make sure that I select a certain card, I tried "soundcard detection...

spell checking does work
I am using windows version. When I try to use spell checking (ispell-buffer), emacs complains no such file or directory ispell. Please advise, Thanks "Kevin" <slimit91@hotmail.com> writes: > I am using windows version. When I try to use spell checking > (ispell-buffer), > emacs complains no such file or directory ispell. > > Please advise, > Thanks maybe u want to install a windows port of ispell ...

telnet to smart_host works
I finally have time to continue my quest to get sendmail working. My sendmail.mc/cf file remains unchanged from the previous thread I started here. I am able to telnet into the smart_host and send an email and have it arive at its destination without problem regardless of any HELO xxx.yyy string I send or any other variation of the smtp commands as long as the To address exists. So why doesn't my sendmail config work? In theory I should be able to script out interactions via telnet to the smart host and be done with sendmail. So what is it that sendmail is sending that could causes &qu...

checking service through telnet.
Hi, Following script i am using to check DNS services on multiple machines, this script is stopping at first successful connection. tt.txt contains ip and hostname(ip;hostname). Please help. ========================================= cat tt.txt | while read xyz do x1=`echo "$xyz" | awk -F";" '{print $1}'`; x2=`echo "$xyz" | awk -F";" '{print $2}'`; echo "IP=$x1"; echo "HOST=$x2"; temp=`telnet $x1 53`; echo $temp > al.tt; grep "Escape" al.tt if [ $? -eq 0 ] ; then echo "--$x1---------OK&qu...

Check Constraint Not Working
I have the following table: SQL> create table nums 2 ( col1 number , 3 col2 number , 4 col3 number , 5 col4 number , 6 col5 number , 7 col6 number 8 ) 9 tablespace users 10 / Table created. Here are the business rules: /* #1 rule if col2 is not null then col1 is not null #2 rule if col3 is not null then col2 is not null #3 rule if col4 is not null then col3 is not null #4 rule if col5 is not null then col4 is not null #5 rule ...

Check Box Not Working
Hi! All of a sudden on a newer version of our application a check box on the "Produce Invoice" form cannot be checked. I did not do any changes to this form at all. Below are the things that I know so far about the problem: 1. On the new version of the application the check box cannot be checked 2. On the previous version of the application the check box can be checked 3. I did not do any changes to the form 4. Using the previous application having the working form, I exported the objects related to the form to the newer version of the application. But it still did not solve...

Send-on-Check does not work
I am using 6.1.1.1 in paid mode under Win2K. The send on check boxes are ticked in both the sending mail and checking mail sections of Tools/Options... The corresponding entry is set to 1 in the .ini file. The message can be sent using the command in the Files menu. What could be going on? JCT On Wed, 23 Jun 2004 20:37:12 -0400, "Jean-Claude Terrier" <jterrier@sogetra.com> wrote: >I am using 6.1.1.1 in paid mode under Win2K. > >The send on check boxes are ticked in both >the sending mail and checking mail sections of >Tools/Opti...

Spell check not working
I've just moved to Eudora 6.1.2 sponsored mode but cannot get spell check to work. It is on the Edit drop-down menu but nothing happens when clicked nor does automatic correction work when set. I've re-downloaded and installed and still no luck. The clx and dlx seem fine. The knowledgebase is no help, nor is the Forum. Can anyone suggest a next step? Pieter. On Sat, 05 Feb 2005 10:28:48 +1100, Pieter <pwessels@ozemail.com.au> wrote: >I've just moved to Eudora 6.1.2 sponsored mode but cannot get spell >check to work. It is on the Edit drop-down menu but nothi...

Spell Checking does not work
I have Eudora 7 PAID. Without warning, the spell checker does not work. I opened Options and checked the Spell Checker and all is set properly. I send forr tech support to Eudora, and of course, never got a reply from them. Tech Support from Eudora SUCKS!! And what did I pay for? Any one out there have a solution to this problem? Many thanks, Guy Henderson On Fri, 21 Apr 2006 16:32:02 GMT, guy henderson <gfhenderson@earthlink.net> wrote: >I have Eudora 7 PAID. >Without warning, the spell checker does not work. >I opened Options and checked the Spell Check...

Checking an image works
I have some code as follows: void myDrawImage(HDC hdc, LPCTSTR name, int width, int height) { GdiplusStartupifnec(); Graphics graphics(hdc); // Create an image Image image(name); // Draw it graphics.DrawImage(&image, 0, 0, width, height); } If name is indeed the filename of an image file, this works fine. But is there some way to check whether image is indeed a valid image? Many thanks. Paul. gw7rib@aol.com wrote: > If name is indeed the filename of an image file, this works fine. But > is there some way to check whether image is indeed a valid ima...

Okay, I've got Postfix, SASL, Mysql and Courier-imap all installed and working (see http://high5.net/howto). I say, "working" because I can telnet to port 25 and port 143,authenticate, then sen
This is a multi-part message in MIME format. --------------000802090008020507040403 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Okay, I've got Postfix, SASL, Mysql and Courier-imap all installed and working on a Mandrake 9.2 box (see http://high5.net/howto). I say, "working" because I can telnet to port 25 and port 143,authenticate, then send mail and access mailboxes respectively. I can check mail and send mail without error in my mail applications. The logs reflect that these things happen and report no errors. However, the ...

Checking my work: PERCENTILES.PRO
This routine, I think many people use, and it has this code: ;; Special treatment for median of data sets with even number of ;; elements: compute average between two center values IF ABS(value[i]-0.5) LT 1.e-3 AND n MOD 2 EQ 0 AND n GT 1 THEN $ thisresult = 0.5 * ( data[ix[long(n/2)]]+data[ix[long(n/ 2)+1]] ) $ ELSE $ thisresult = data[ix[ind]] If you should happen to give PERCENTILES() a two-element array, this will crash. What's more, if N=4, this gives the median as MEAN(DATA[2:3]), which is clearly wrong. Should be: thisre...

MouseWheelOFF does not work on check boxes
We have been using Stephen Lebans excellent MouseHook.dll to disable the mouse wheel on forms in our MSAccess 2002 application. We have discovered a weakness for which I do not have an answer but others may benefit from my observations. We have a form with about 60 controls of various types which had a seemingly intermittent failure in the MouseWheelOFF setting. It turns out the mouse wheel scrolling to other records occurred only when either of the two check boxes on the form had focus. We have done a workaround by removing the check boxes from tab order but if anyone has any other ideas ...

mass check out PDM works
This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C6C1EC.E93E3A90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello In soldworks service Pack 0 . there was a fuction of mass check out. = solidworks has since removed this functionality in PDMworks. Does anyone Know of a 3rd party or Add In that will extract multiple = documents from PDMworks. Thanks ------=_NextPart_000_0020_01C6C1EC.E93E3A90 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HT...

How does signature check in CPAN work?
Hello, I searched through all modules of the CPAN command line interface, but I couldn't find out how CPAN checks for the GPG signature. Does CPAN automatically download a public key and import it to my keyring or do I have to do so myself? Which keys does the CPAN script trust? CU Manuel Am Thu, 25 Sep 2008 13:02:10 +0200 schrieb Manuel Reimer <mreimer@expires-30-09-2008.news-group.org>: > Hello, >=20 > I searched through all modules of the CPAN command line interface, > but I couldn't find out how CPAN checks for the GPG signature. >=20 > Does CPAN a...