SOT: Nix shell script to test if CF is running on port xxxx
I know I have seen this done somewhere! 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 This is for OS X but should work on any 'Nix flavor. Any help would be greatly appreciated TIA Dick [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: SOT: Nix shell script to test if CF is running on port xxxx
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. -- Tom Chiverton Advanced ColdFusion Programmer Tel: +44(0)1749 834997 email: [EMAIL PROTECTED] BlueFinger Limited Underwood Business Park Wookey Hole Road, WELLS. BA5 1AF Tel: +44 (0)1749 834900 Fax: +44 (0)1749 834901 web: www.bluefinger.com Company Reg No: 4209395 Registered Office: 2 Temple Back East, Temple Quay, BRISTOL. BS1 6EG. *** This E-mail contains confidential information for the addressee only. If you are not the intended recipient, please notify us immediately. You should not use, disclose, distribute or copy this communication if received in error. No binding contract will result from this e-mail until such time as a written document is signed on behalf of the company. BlueFinger Limited cannot accept responsibility for the completeness or accuracy of this message as it has been transmitted over public networks.*** [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: SOT: Nix shell script to test if CF is running on port xxxx
"Wookey Hole" Road <---<< a place where Han Solo sometimes went? :OD -Original Message- From: Thomas Chiverton [mailto:[EMAIL PROTECTED] Sent: 06 September 2004 17:02 To: CF-Talk Subject: Re: SOT: Nix shell script to test if CF is running on port -- Tom Chiverton Advanced ColdFusion Programmer Tel: +44(0)1749 834997 email: [EMAIL PROTECTED] BlueFinger Limited Underwood Business Park Wookey Hole Road, WELLS. BA5 1AF Tel: +44 (0)1749 834900 Fax: +44 (0)1749 834901 web: www.bluefinger.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: SOT: Nix shell script to test if CF is running on port xxxx
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]
Re: SOT: Nix shell script to test if CF is running on port xxxx
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]
Re: SOT: Nix shell script to test if CF is running on port xxxx
Josh I've done that, here's the synopsis: NETSTAT(1) BSD General Commands Manual NETSTAT(1) NAME netstat - show network status SYNOPSIS netstat [-AaLlnW] [-f address_family | -p protocol] [-M core] [-N system] netstat [-gilns] [-f address_family] [-M core] [-N system] netstat -i | -I interface [-w wait] [-abdgt] [-M core] [-N system] netstat -s [-s] [-f address_family | -p protocol] [-M core] [-N system] netstat -i | -I interface -s [-f address_family | -p protocol] [-M core] [-N system] netstat -m [-M core] [-N system] netstat -r [-Aaln] [-f address_family] [-M core] [-N system] netstat -rs [-s] [-M core] [-N system] when i run netstat w/o any parms, it does not show some ports that I know are active (80, 9090, etc) lost? Dick Richard:~ richard$ netstat Active Internet connections Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 10.0.1.2.54157 idisk.mac.com.http ESTABLISHED tcp4 0 0 10.0.1.2.54156 adsl-67-124-145-.hp-pd SYN_SENT tcp4 0 0 10.0.1.2.53939 mail.mac.com.imap ESTABLISHED tcp4 0 0 localhost.ipp localhost.53844 ESTABLISHED tcp4 0 0 localhost.53844localhost.ipp ESTABLISHED tcp4 0 0 localhost.53843localhost.ipp CLOSE_WAIT tcp4 0 0 localhost.53490localhost.51004 CLOSE_WAIT tcp4 0 0 localhost.53489localhost.51004 CLOSE_WAIT tcp4 0 0 localhost.53353localhost.51004 CLOSE_WAIT tcp4 0 0 localhost.53352localhost.51004 CLOSE_WAIT tcp4 0 0 10.0.1.2.62793 idisk.mac.com.http CLOSE_WAIT tcp4 0 0 10.0.1.2.61312 mail.mac.com.imap ESTABLISHED tcp4 0 0 localhost.59549localhost.ipp CLOSE_WAIT tcp4 0 0 localhost.59548localhost.ipp CLOSE_WAIT tcp4 0 0 10.0.1.2.49357 mail.mac.com.imap ESTABLISHED tcp4 0 0 localhost.netinfo-loca localhost.972 ESTABLISHED tcp4 0 0 localhost.972 localhost.netinfo-loca ESTABLISHED udp4 0 0 localhost.53331localhost.1023 udp4 0 0 *.50421 *.* udp4 0 0 *.**.* udp4 0 0 *.svrloc *.* udp4 0 0 *.**.* udp4 0 0 *.**.* udp4 0 0 localhost.49160localhost.1022 udp4 0 0 localhost.49159localhost.1022 udp4 0 0 localhost.1022 *.* udp4 0 0 localhost.1023 *.* udp4 0 0 10.0.1.2.ntp *.* udp4 0 0 localhost.ntp *.* udp4 0 0 *.ntp *.* udp4 0 0 *.mdns *.* udp4 0 0 *.ipp *.* udp4 0 0 *.bootpc *.* udp4 0 0 localhost.netinfo-loca *.* udp4 0 0 *.syslog *.* udp6 0 0 *.514 *.* icm6 0 0 *.**.* icm6 0 0 *.**.* Active LOCAL (UNIX) domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr 2f7fdc8 stream 4781 00000 2f7f5b0 stream 0 00000 2f7f9d8 stream 0 00 2f7f9a000 2f7f9a0 stream 0 00 2f7f9d800 2f7fe70 stream 0 00000 2f7f620 stream 0 00000 2f7fb60 stream 0 00000 1d69460 stream 0 00000 2f7fd58 stream 0 00000 2f7fd20 stream 0 00000 2f7f930 stream 0 00000 2f7fc78 stream 0 00000 2f7ffc0 stream 0 00000 1d69150 stream 0 00000 2f7fc40 stream 0 00000 2f7fa48 stream 0 00 2f7fce800 2f7fce8 stream 0 00 2f7fa4800 2f7fcb0 stream 0 00000 2f7fa10 stream 0 00 2f7fab800 2f7fab8 stream 0 00 2f7fa1000 2f7ff18 stream 0 00 1d6903800 1d69038 stream 0 00 2f7ff1800 1d69188 stream 0 0 2b82bf00
Re: SOT: Nix shell script to test if CF is running on port xxxx
Dick Applebaum wrote: > when i run netstat w/o any parms, it does not show some ports that I > know are active (80, 9090, etc) > > lost? > interesting...not sure why that would be. I run a farm of linux servers and the following worked fine for me on my systems: netstat -alpn | grep (my port here) so your main goal is just to see if the service is running? why not just run the cfstat utility? or are really trying to get the port too? you can also check the jrun.xml file to see what port it is setup to run on here: /opt/coldfusionmx/runtime/servers/default/SERVER-INF/jrun.xml Hope that helps! -Josh > Dick > > Richard:~ richard$ netstat > Active Internet connections > Proto Recv-Q Send-Q Local Address Foreign Address > (state) > tcp4 0 0 10.0.1.2.54157 idisk.mac.com.http > ESTABLISHED > tcp4 0 0 10.0.1.2.54156 adsl-67-124-145-.hp-pd > SYN_SENT > tcp4 0 0 10.0.1.2.53939 mail.mac.com.imap > ESTABLISHED > tcp4 0 0 localhost.ipp localhost.53844 > ESTABLISHED > tcp4 0 0 localhost.53844localhost.ipp > ESTABLISHED > tcp4 0 0 localhost.53843localhost.ipp > CLOSE_WAIT > tcp4 0 0 localhost.53490localhost.51004 > CLOSE_WAIT > tcp4 0 0 localhost.53489localhost.51004 > CLOSE_WAIT > tcp4 0 0 localhost.53353localhost.51004 > CLOSE_WAIT > tcp4 0 0 localhost.53352localhost.51004 > CLOSE_WAIT > tcp4 0 0 10.0.1.2.62793 idisk.mac.com.http > CLOSE_WAIT > tcp4 0 0 10.0.1.2.61312 mail.mac.com.imap > ESTABLISHED > tcp4 0 0 localhost.59549localhost.ipp > CLOSE_WAIT > tcp4 0 0 localhost.59548localhost.ipp > CLOSE_WAIT > tcp4 0 0 10.0.1.2.49357 mail.mac.com.imap > ESTABLISHED > tcp4 0 0 localhost.netinfo-loca localhost.972 > ESTABLISHED > tcp4 0 0 localhost.972 localhost.netinfo-loca > ESTABLISHED > udp4 0 0 localhost.53331localhost.1023 > udp4 0 0 *.50421 *.* > udp4 0 0 *.**.* > udp4 0 0 *.svrloc *.* > udp4 0 0 *.**.* > udp4 0 0 *.**.* > udp4 0 0 localhost.49160localhost.1022 > udp4 0 0 localhost.49159localhost.1022 > udp4 0 0 localhost.1022 *.* > udp4 0 0 localhost.1023 *.* > udp4 0 0 10.0.1.2.ntp *.* > udp4 0 0 localhost.ntp *.* > udp4 0 0 *.ntp *.* > udp4 0 0 *.mdns *.* > udp4 0 0 *.ipp *.* > udp4 0 0 *.bootpc *.* > udp4 0 0 localhost.netinfo-loca *.* > udp4 0 0 *.syslog *.* > udp6 0 0 *.514 *.* > icm6 0 0 *.**.* > icm6 0 0 *.**.* > Active LOCAL (UNIX) domain sockets > Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr > 2f7fdc8 stream 4781 00000 > 2f7f5b0 stream 0 00000 > 2f7f9d8 stream 0 00 2f7f9a000 > 2f7f9a0 stream 0 00 2f7f9d800 > 2f7fe70 stream 0 00000 > 2f7f620 stream 0 00000 > 2f7fb60 stream 0 00000 > 1d69460 stream 0 00000 > 2f7fd58 stream 0 00000 > 2f7fd20 stream 0 00000 > 2f7f930 stream 0 00000 > 2f7fc78 stream 0 00000 > 2f7ffc0 stream 0 00000 > 1d69150 stream 0 00000 > 2f7fc40 stream 0 00000 > 2f7fa48 stream 0 00 2f7fce800 > 2f7fce8 stream 0 00 2f7fa4800 > 2f7fcb0 stream 0 00000 > 2f7fa10 stream 0 00 2f7fab800 > 2f7fab8 stream 0 00 2f7fa1000 > 2f7ff18 stream 0 00 1d6903800 > 1d69038 stream 0 00 2f7ff1800 > 1d69188 stream 0 0 2b82bf0000 > /tmp/webdavDtD2qQ > 2f7fd90 stream
Re: SOT: Nix shell script to test if CF is running on port xxxx
Josh Thanks for your help Based on what you posted, I did some experimenting and found something that appears to work --the first 2 tests were run after the server (9090 in this case) was started, but had not yet become ready. The 3rd test shows the server is ready. So it, appears that I have something that I can test for in a loop. Is there a "best practices" wway to test for something like this -- say with a sleep for a few seconds, and a max number of iterations so it doesn't loop for ever? Dick Richard:~ richard$ netstat -aln | grep 9090 Richard:~ richard$ netstat -aln | grep 9090 Richard:~ richard$ netstat -aln | grep 9090 tcp46 0 0 *.9090 *.* LISTEN Richard:~ richard$ On Sep 6, 2004, at 1:57 PM, Josh wrote: > > > when i run netstat w/o any parms, it does not show some ports that I > > know are active (80, 9090, etc) > > > > lost? > > > interesting...not sure why that would be. > > I run a farm of linux servers and the following worked fine for me on > my > systems: > > netstat -alpn | grep (my port here) > > so your main goal is just to see if the service is running? > > why not just run the cfstat utility? or are really trying to get the > port too? > > you can also check the jrun.xml file to see what port it is setup to > run > on here: > /opt/coldfusionmx/runtime/servers/default/SERVER-INF/jrun.xml > > Hope that helps! > > -Josh > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: SOT: Nix shell script to test if CF is running on port xxxx
On Monday 06 Sep 2004 17:39 pm, Adrian Lynch wrote: > "Wookey Hole" Road <---<< a place where Han Solo sometimes went? :OD Me like :-) -- Tom Chiverton Advanced ColdFusion Programmer Tel: +44(0)1749 834997 email: [EMAIL PROTECTED] BlueFinger Limited Underwood Business Park Wookey Hole Road, WELLS. BA5 1AF Tel: +44 (0)1749 834900 Fax: +44 (0)1749 834901 web: www.bluefinger.com Company Reg No: 4209395 Registered Office: 2 Temple Back East, Temple Quay, BRISTOL. BS1 6EG. *** This E-mail contains confidential information for the addressee only. If you are not the intended recipient, please notify us immediately. You should not use, disclose, distribute or copy this communication if received in error. No binding contract will result from this e-mail until such time as a written document is signed on behalf of the company. BlueFinger Limited cannot accept responsibility for the completeness or accuracy of this message as it has been transmitted over public networks.*** [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]