Dick,

use the man pages to see the options for netstat...I don't run OSX or
I'd give you the fix.

just type:
man netstat

HTH

-Josh

Dick Applebaum wrote:

> On Sep 6, 2004, at 9:02 AM, Thomas Chiverton wrote:
>
> > On Saturday 04 Sep 2004 03:08 am, Dick Applebaum wrote:
> >  > I want to write a 'Nix shell script to see if a cf server instance
> > is
> >  > running (accepting requests) an a given port - say 8101
> >
> >  netstat -alpn | grep 8101
> >  then pipe to something like 'awk {print $8}' that will get you the
> > process
> >  name, just grep for whatever your cf server shows up as when you run
> > the
> >  script by hand.
> >
>
> On OS X, if I use the above I get:
>
> Richard:~ richard$ netstat -alpn | grep 8101
> netstat: n: unknown or uninstrumented protocol
> Richard:~ richard$
>
> So I try
>
> Richard:~ richard$ netstat -alp | grep 8101
> netstat: option requires an argument -- p
> usage: netstat [-Aan] [-f address_family] [-M core] [-N system]
>         netstat [-bdghimnrs] [-f address_family] [-M core] [-N system]
>         netstat [-bdn] [-I interface] [-M core] [-N system] [-w wait]
>         netstat -m [-M core] [-N system]
> Richard:~ richard$
>
> So, I listed the protocols -- & I don't know which one(s) to check for.
>
> What I am trying to do is write a script that automates CF startup, and
> sleeps (or loops) until CF is up and the port is accepting http
> requests.
>
> I have modified an example I found to do this by invoking a Perl script
> that, in turn, interacts with telnet  ( apparently shell scripts have
> difficulty interacting ).
>
> #!/usr/bin/perl
> use Net::Telnet;
> $telnet = new Net::Telnet ( Timeout=>30, Port=>8081, Errmode=>'die');
> $telnet->open('localhost');
> $telnet->waitfor('/220/');
> $telnet->print('hello just-testing.org');
> ($output)=$telnet->waitfor('/250/');
> $telnet->print('quit');
>
> I'd rather not use an additional Perl script if possible)
>
> I can brute force a delay using a long sleep, but this is not very
> elegent
>
> Maybe the expect command will allow me to script telnet interaction.
>
> If you could point me in the right direction, I will appreciate it.
>
> TIA
>
> Dick
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to