03-17-04 09:41 PM
Hi,
I'm fairly new to shell programming so this is hopefully just a simple
syntax error.
What I'm trying to do is to get an ip address from "file1.txt", ping it once
and put this in "file2.txt". Here's my code:
address = awk $1 file1.txt;
ping "$address"-c 1 >> file2.txt;
echo
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~">>file2.txt;;
can anybody tell me where I'm going wrong?
file1.txt is set out as below:
192.168.0.1
192.168.0.2
13.65.98.2
255.255.25.255
156.285.24.2
1.2.3.4
etc... jus a list of IP addresses, each on a new line in dotted decimal
form.
and hopefully file2 will look like this:
PING 192.168.0.1 (192.168.0.1) from 192.168.0.2 : 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=128 time=0.214 ms
--- 192.168.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% loss, time 0ms
rtt min/avg/max/mdev = 0.214/0.214/0.214/0.000 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
PING 192.168.0.2 (192.168.0.2) from 192.168.0.2 : 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=128 time=0.214 ms
--- 192.168.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% loss, time 0ms
rtt min/avg/max/mdev = 0.214/0.214/0.214/0.000 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
PING 13.65.98.2 (13.65.98.2) from 192.168.0.2 : 56(84) bytes of data.
64 bytes from 13.65.98.2: icmp_seq=1 ttl=128 time=0.214 ms
--- 13.65.98.2 ping statistics ---
1 packets transmitted, 1 received, 0% loss, time 0ms
rtt min/avg/max/mdev = 0.214/0.214/0.214/0.000 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
and so on...
any help would be much appreciated.
thanks for any replies
Pete
[ Post a follow-up to this message ]
|