How to check if telnet works?

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
SQ
8/18/2006 9:23:23 PM
comp.unix.shell 15265 articles. 0 followers. Post Follow

1 Replies
418 Views

Similar Articles

[PageSpeed] 35
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
Stephane
8/19/2006 10:15:32 AM
Reply:
Similar Artilces:

check one two check check
check check one twoo Stifler wrote: > check check one twoo You're supposed to say that into a microphone. Here it goes like this: "this is a test, please ignore." -- _______________________________________________________________________ Christopher R. Carlen Principal Laser/Optical Technologist Sandia National Laboratories CA USA crcarle@sandia.gov -- NOTE: Remove "BOGUS" from email address to reply. ...

How to work with directories and files with spaces
hi I am working in unix and i have some directories names with spaces eg ABC DEF A how can i work effectively with spaces in directory/file names in python? sometimes when i do os.path.join(dir_with_spaces,"-somestring" ) , it gives me "-somestring" as the name only...without ABC DEF A it should give me ABC DEF A-somestring as the directory name thanks s99999999s2003@yahoo.com wrote: > hi > > I am working in unix and i have some directories names with spaces > eg ABC DEF A > how can i work effectively with spaces in directory/file names in > python?...

He'll be working of feminist Franklin until his museum illustrates admiringly.
the world is in fact unconquerable, and could only become conquerable through slow demographic changes which a government with wide powers can easily avert. The second danger, also, is only a theoretical one. The masses never revolt of their own accord, and they never revolt merely because they are oppressed. Indeed, so long as they are not permitted to have standards of comparison, they never even become aware that they are oppressed. The recurrent economic crises of past times were totally unnecessary and are not now permitted to happen, but other and equally la...

PATH Check Code Not Updating Current Directory #2
Hello, A previous post by n6vc on Sep 15, 12:29 pm: \<< A B C D E BarSag 6 \->LIST "Foot Measurement" { { "A:" "Moveable Foot, Outbrd to Inbrd" } { "B:" "Movable Foot, Inbrd to Dial X" } { "C:" "Dial X to Dial Y" } { "D:" "Dial Y to Fixed Foot, Inboard" } { "E:" "Fixed Foot, Inboard to outboard" } { "BarSag" "Measure Bar Sag" } } { 2 1 } { 0 0 0 0 0 0 } 5 ROLL INFORM \>> was modified by me to ensure the current path is { HOME Alignment } before run...

Eudora filter isn't working correctly
I have a filter to check whether my email address is in the "To:" field, and if not, send the message to the trash. By changing my system clock and then filtering, I've determined that this one filter is sending messages from one acquaintance into the trash. Yet right there, in the "To:" header is my e-mail address. Why is this filter missing this criteria? Other filters seem to be working fine. PowerBook G3/400; OS X 10.3.7; Eudora Pro 6.2 -- Please, no "Go Google this" replies. I wouldn't ask a question here if I hadn't done that already. ...

Checking for XSS ?
All, Does the check below ensure that the files are originating from my server, i.e. to prevent or detect any type of XSS ? Or is the HTTP_HOST easily spoofed ? function test ($refer) { if (!stristr($refer, $_SERVER["HTTP_HOST"])) { die(); } else { } } test ($_SERVER["HTTP_HOST"]); Any better ideas ? Many thanks. "StinkFinger" <stinky@pinky.com> wrote in message news:<10alovs4861j233@corp.supernews.com>... > All, > Does the check below ensure that the files are originating from my server, > i.e. to prevent or detect > any type of XSS ...

Need help to check/extend a proof.
Another question from the archive: L = {<M1><M2><M3>|L(M1)!=L(M2) and L(M2)!=L(M3) and L(M1)!=L(M3)} Is this recursive? RE but not recursive? Not RE? <Mi> is the encoding of TM Mi. I started my proof with a 2 machine case: We know that 1. L2 = {<M1><M2>|L(M1)=L(M2)} is undecidable 2. L2' = {<M1><M2>|L(M1)!=L(M2)} is the complement of L2 So we know that L2' is not recursive. I try to proof that L2' is RE: To prove L(M1)!=L(M2), we only need one string that L(M1) accepts and L(M2) does not. So we construct a non-deterministic TM ...

Network Configurations when working offline
I am a newbie to working with Apache, so I appoligize if this has been asked previously. I am currently working with a laptop (win2000) which has Apache 2.0.46, Tomcat 4.1.24, and mysql installed. The apache settings allow me to work while connected to my intranet, as well as when a hub (no network conductivity) connected to the laptop. What I am unable to do is work while the hub is not connected to the laptop. I continue to receive a page can not be displayed message. I have looked everywhere I can think of to find a solution. I have attempted entering 127.0.0.1 into the address, as wel...

Re: Printing does not work reliably under RedHat FC1 with gimp-print and Epson stylus photo 890 printer
On Sat, 24 Jul 2004 07:52:50 +0000, Jeff Silverman wrote: > Hi, I am running RedHat Fedora Core 1 with cups and gimp-print using an > Epson stylus photo 890 printer connected via USB. When it works, it is > a pleasure and a joy to work with, the equal of anything available under > MS-Windoze. Huh? Only equal!!!? That is pretty bad by Linux standards to be merely "equal," but I guess it depends on your definition of "equal." > But when it fails, the only way to clear the problem seems > to be to remove the queue from cups, shutdown the printer, cycl...

Dev-Pascal Range checking.
Hi Guys, I am trying out the Dev-Pascal compiler and am trying to implement range checking with the following code: program Untitled; type grade = 'A'..'E'; var my_grade : grade; begin my_grade := 't'; writeln('expecting some sort of runtime error'); readln end. I kind of expected a runtime error, but the assignment to my_grade is happily accepted, any ideas. Thanks, Kevin Wright. On 2004-10-14, news.ntlworld.com <kwright@nospam.com> wrote: > Hi Guys, > > I am trying out the Dev-Pascal compiler and am trying to im...

checkbox bug: never checked on read
Hi, the following problem only occurs with wvwtools, xharbour without wvwtools works correct: problem setting default value for checkbox as checked: #include "wvwtools.ch" local bVar1 := .t. local bVar2 := .f. @ 10,10 get bVar1 checkbox caption "bvar-1" @ 12,10 get bVar2 checkbox caption "bvar-2" read don't show bVar1 as checked. both checkboxes are unchecked. how can I set bVar1 as checked?!? regards Dirk On 8 nov, 17:23, dirk <dirk.bl...@t-online.de> wrote: > Hi, > > the following problem only occurs with wvwtools, xharbour without >...

check it out this is awesome
http://www.darkwars.org/index.php?a=click&id=92490 kenshin13 wrote: >(snip) Who the fsck are you, and why should we follow a link, described merely as "awesome", posted by some idiot who has never-before posted in here? chrisv blithely blithered > kenshin13 wrote: > >>(snip) > > Who the fsck are you, and why should we follow a link, described > merely as "awesome", posted by some idiot who has never-before posted > in here? It has a click ID, most likely an advertisement. he could be getting paid by the click. That post is probably ...

Upload file format checking
Hi, What is the best way to validate that an uploaded file (using CGI.pm) is a tab delimited table of the correct format? I.e. every line has the same number of columns as the header, and the header has to match a predefined set of table headers. Should it be done as the file is read in? After I store it to disk? Suggestions for implementations? Thanks, B Bryan <spam@nospam.com> wrote: > Hi, > > What is the best way to validate that an uploaded file (using CGI.pm) is > a tab delimited table of the correct format? I.e. every line has the > same number of columns...

how to check installed RAM module and free slots
hi, please let me know how to check installed RAM module and slot information. SUN Sol8,Sol9 search google for memconf. /Arjun On Mar 6, 3:08 am, "nad" <prashanth.na...@gmail.com> wrote: > hi, > please let me know how to check installed RAM module and slot > information. SUN Sol8,Sol9 ...

spell checking in emacs
how can I add a dictionary to the predefined dict's list in emacs? -- �������� � M2 - ��������� �̦��Ԧ �������� Opera: http://www.opera.com/m2/ -- �������� � M2 - ��������� �̦��Ԧ �������� Opera: http://www.opera.com/m2/ ...

Working with Previous Observation
I would like to change the value of the current observation to the value of the observation before it (and sometimes ahead of it) if the current value is missing. Basically I want to do this: replace x=x[_n-1] if x=. by employee and replace x=x[_n+1] if x=. by employee I would also like to be able to do this: b=1 if(x=x[_n-1] or x=x[_n+1]) by employee Either proc sql or data step is fine. What if the previous obs doesn't equal the next obs? I know that there exists a way to work with the previous obs with retain, but can't tell you exactly. As for working with the next obs.... i&#...

Script that checks for existence of file on remote server.
Hi - I would like to know if there is a way in shell scripting to check the existence of a file after FTP? Basically if the file does not exist in a certain directory, the shell script should fail. thanks, val vegas_girlie <minnie_valerie@hotmail.com> wrote: > I would like to know if there is a way in shell scripting to check the > existence of a file after FTP? Basically if the file does not exist in > a certain directory, the shell script should fail. if [ ! -f somefile ]; then exit 1 fi to check for the existence of a certain file. Yours, Laurenz Albe If I read the ...

Checking on a checked radio-button
I have a few radio-buttons in my gui application. I want to implement the following behavior: If the user clicks on a radio-button that is already checked, it will stay checked. I tried the following code on a radio-button called �radioModeA�, but it doesn�t work. Can someone help please? (I�m working with Matlab 6.5, so I don�t have button-group). function radioModeA_Callback(hObject, eventdata, handles) Val = get(hObject,'Max'); if (get(hObject,'value') ==Val) set(hObject, 'value', Val); set(handles.radioModeB, 'value', 0); else set(handles.radio...

Why does #include cause my java navbar not to work?
Could you help me to solve the following problem: I have an apMenu navbar on my page http://www.wahlstroem.dk, but when I want to include a top-menu from the root directory using <!--#include file="top.shtml"-->, this kills the links in the applet. The code is <HTML> <HEAD> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <LINK REL="SHORTCUT ICON" href="favicon.ico"> <LINK REL="stylesheet" HREF="style.css" TYPE="text/css"> <TITLE>Storeforside</TITLE> <meta name=&quo...

why doesn't this if statement with a prior assignment work?
#!/bin/bash # search dir _IDIR=${1} # input file with codes _IFL=${2} _START=1 _END=44 echo "// __ _IDIR: ${_IDIR}" echo "// __ _IFL: ${_IFL}" echo "// __ _START: ${_START}" echo "// __ _END: ${_END}" if [ -n $3 ] then _START=$3 fi if [ -n $4 ] then _END=$4 fi echo " ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ " echo "// __ _IDIR: ${_IDIR}" echo "// __ _IFL: ${_IFL}" echo "// __ _START: ${_START}" echo "// __ _END: ${_END}" # lbrtchx:why doesn\'...

how to check if autogenerated checkbox is checked or not ?
Hello, I have small script which generates some listboxes. Their names are listXX (list01, list02, list03....). How to check if there are checked or not ? If I have 1 listbox and have it's name I do $_POST['list01']. But what to do in that situation ? Sincerely, Dmitrij I am sorry for my mistake. I mean check box and not $_POST... but $list01 = "on" :) <dkultasev@gmail.com> wrote in message news:1192224080.641241.93210@v23g2000prn.googlegroups.com... > Hello, > I have small script which generates some listboxes. Their names are > listXX (list01, lis...

unixpath command on UWIN not working for me
I am using UWIN (unix/linux emulator for windows 95,98,2000,xp) and Micro Focus COBOL Net Express. I have written korn shell scripts to compile the COBOL source code. My problems are caused by the different pathnames for unix/linux vs Windows Unix/linux expects forward slashes & Windows backward slashes & drives C: etc I compensate for this by moving my source into my output subdir, and changing in there to compile. That works fine for programs that dont have copybooks. COBOL provides the 'COBCPY' environmental variable to point to the copybook directory. If in my un...

The XMLHttpRequestObject does not seem to work on IE 6 or 7
Hello JavaScript group, I am trying to use/learn something about using AJAX (aka JavaScript) for web pages, etc. I am trying to use code out of "Ajax Web Applications" by Matthew Eernisse. This is just a simple affair using two html pages (ajaxtest.html and ajaxmonitor.html). It the case of ajaxtest.html all it does is flash a window.alert on the screen with the word "OK". The ajaxmonitor.html polls the server and has a little timing loop. Both of these pages work in Firefox and Safari. Needless to say IE 6 and 7 i see no results. This is on several different computer...

Re: Check for empty dataset #3
Dear Nicole, During the compilation (so far before execution) phase the number of observations (NOBS) already is set to your variable HowMany. Now, if the dataset is really empty the implicit DATA step loop terminates right after the SET statement, so your code never runs. The easiest and nicest solution in your case is to combine the code for both empty and non-empty datasets in one data step as below. The tric is to force running at least some code with an empty dataset by moving that code to before the SET statement; and as HowMany already is known there (from the compilation phase) this i...

Menu works only one time
Hi .. &nbsp; I am currently trying to implement a menu. &nbsp; I have a button save and the X in the upper right corner. the whole thing is a modal window, which is called from my application (it creates and saves a configuration). &nbsp; Everything works fine as long as I press the "Save" Button. But: When I press the X, the menu disappears (as expected) but when I try to open it again from the main menu, labview seems to hang. I can only close it with Ctrl-Alt-Del :( &nbsp; What could be the cause for this ? &nbsp; Thanks Tom I forgot to say. &nbsp; I try ...