Thanks to: Ed Sexton Espen Martinsen Andrew J Caines I found the "cleanest" myself at shelldorado which is a brilliant site for shell script resources: http://www.shelldorado.com/shelltips/script_programmer.html#networking Here is a copy of the refering section of the above website: --- [Note: the following examples will work only with standard ksh implementations. They will not work with the Linux Korn Shell pdksh.] Most Korn Shells (/bin/ksh) have sparsely documented, build-in networking functions. Example: $ date= $ read date < /dev/tcp/127.0.0.1/13 $ echo $date Wed Feb 10 00:45:39 MET 1999 This command opens a TCP connection to the IP address 127.0.0.1 (the local loopback IP address), and connects to the port "13" (daytime, see /etc/services). The current date and time is returned, and assigned to the variable "date". Note that the "/dev/tcp/*" directories do not have to exist; the file names are special to the Korn Shell and are interpre! ted by the shell internally. Only numerical ip addresses and port numbers are supported; "read date < /dev/tcp/localhost/daytime" does not work. --- On Fri, Jan 17, 2003 at 02:42:31AM -0500, Andrew J Caines wrote: >Sugan, > >> I wish to write a Korn shell script that checks whether an FTP port (20 or >> 21) on a remote server is up before the ftp continues. I've heard of the NC >> command on google but I cannot find it on Solaris. > >The "nc" binary is "netcat"[1] - a great general purpose network >connection tool ideal for scripting. It's not part of Solaris, but you can >build it or install a package. > >> It is most prefered that the manner in which this task is completed is as >> simple as possible without using third party programs. > >You may want to look into using "mconnect". It's a simple tool which >allows you to specify a port (with -p) and do standard I/O, but I don't >know how suitable it is for scripting. Avoid telnet. > > >[1] See eg. ftp://coast.cs.purdue.edu/pub/tools/unix/netutils/netcat/ On Fri, Jan 17, 2003 at 08:44:35AM +0100, Espen Martinsen wrote: >precompiled: > >ftp://ftp.sunfreeware.com/pub/freeware/sparc/8/nc-110-sol8-sparc-local.gz > >source: >ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/nc-110.tar.gz > >info/doc/homepage: >http://www.sans.org/infosecFAQ/audit/netcat.htm > >Mvh On Fri, Jan 17, 2003 at 01:49:01AM -0600, Ed Sexton wrote: >Hi Sugan- > >Hopefully this info helps, it should be pretty solid. wget-1.5.3 is >shipped on the Solaris 8 Bonus disk. Apologies if you already know about >this, but in case not; > >The utility wget is very good at connecting to an FTP server. If a >user/pass is not specified it will use anonymous login. > >If your FTP server does not allow anonymous, then you can specify it in >the command, eg; wget ftp://username:password@ftp.mozilla.org/Welcome > >You can download a small file, then test return code, 0=success. > >$ wget -q ftp.mozilla.org/Welcome >$ echo $? >0 > ># This file does not exist on server. > >$ wget -q ftp.mozilla.org/Welcome_no >$ echo $? >1 > >There may even be a command switch that removes the file once downloaded. > >I tried doing this via echo "quit" | telnet localhost ftp, but kept >getting a return code of 1. You might be able to do something equivalent >with either expect or a .netrc file. ______________________________________________ "The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful. Absa is liable neither for the proper, complete transmission of the information contained in this communication, nor for any delay in its receipt, nor for the assurance that it is virus-free." _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Fri Jan 17 05:19:45 2003
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:01 EST