Saturday, February 9, 2013

what's the linux equiv. to ctrl-break for the ping command?

linux ping
 on Unix ja Linux
linux ping image



Tree


ctrl-c in linux is the same as ctrl-c in windows, not ctrl-break. That stops the ping, I want to leave the ping running as in ctrl-break.
in windows you can run a ping continuously; ping -t host, then press ctrl+break to get the stats and leave the ping running.
How does one do this in Linux?



Answer
Yeah.. CTRL break stops the script like Ctrl +C in Linux. Neither leaves the script running as far as I know.

If you want to ping something constantly and then only check in on it when you feel the need to see that stats.... Hm.... Um... Okay.. okay.. here we go.

#> sudo su
(password)

#> nano /usr/bin/isup
(((PASTE THE FOLLOWING:)))
#! /bin/bash
# isup pings a given host once every 30 seconds then drops
# the info that can be read at will.
# Grab the line
#
if [ $# -eq 0 ];then
echo "usage: isup <hostname or ip>"
exit 0
else
THEHOST="$1"
. /usr/bin/isup.go
fi
##### END OF FILE
(quit and save ctrl + X, yes enter)

#> nano /usr/bin/isup.go
#((( PASTE THE FOLLOWING )))
function RUNIT () {
ping -c1 "$THEHOST" >> /usr/bin/isup.log
sleep 30
RUNIT
}
RUNIT &
#### END OF FILE
( save and quit)

#> nano /usr/bin/isread
#((( PASTE THE FOLLOWING:)))

#! /bin/bash
cat /usr/bin/isup.log | less
#### END OF FILE
(quit and save)

#> touch /usr/bin/isup.log
#> chmod 755 /usr/bin/isup*
#> chmod 777 /usr/bin/isup.log # could probably use 666

Okay ...
so now you have a PRIMATIVE program that once invoked pings a server once every 30 seconds in the background and pipes the results to a file which can be read at any time.
USAGE:
#> isup www.google.com # start it
#> isread # read it
to stop it, you will need to:
#> ps aux | grep isup
then
#> kill <pid of isup>

That'll do but its a kludge...

I can ping other winXP PC with my Linux laptop, how to file sharing for these 2?




Hitler





Answer
You can use WinSCP to access the Linux computer from the Windows computer. You can setup Samba on the linux comp and access the windows shared folders from linux.
Hope this helps.

i installed newly two linux machines?how can i interact with them without using PING?




kranthi d





Answer
You use ping to test a connection, not to do normal data transfers, etc.




Powered by Yahoo! Answers

No comments:

Post a Comment