Thanks for the reply man. My ping.txt contains the ping of ~5 min of the ping itself. i'd like a ping.txt that holds a continuous ping all day long.
In linux, if you use ping without using parameters like -c, -w or -W; ping will just run continuously until you stop/kill the process.
The only exception to this is if your distro has an alias set up for ping, which might specify a count.
So if you only got 5 minutes, perhaps ping is set up as an alias using the -w (deadline) option and a value of 300.
e.g.
alias ping='ping -w300'
The way to check whether a command has been aliased is to use the
type
command:
e.g.
type ping
If it has been aliased, you will see something like:
ping is aliased to 'ping -w300'
If it has not been aliased, you will see something like:
ping is hashed (/bin/ping)
Which means that it's a binary executable.
If an alias has been set up, it means that each time you type:
ping hostname >> ping.txt
The shell will expand that to:
ping -w300 hostname >> ping.txt
To remove an alias - you can either unalias ping - which will affect only the current teminal session. Or to permanently remove it - you can remove the alias from your .bashrc (or whichever dot file the alias has been set up in), OR simply escape the alias using
\ping
instead of
ping
.
\ping
will escape any aliases set up for ping and will only pass the parameters that you specify to ping. In fact if you prepend a backslash before any command, it will escape any aliases for that command.
So typically things like
ls
and
grep
will have aliases set up that set some default parameters. And very often these aliases are extremely handy. But sometimes you might need their output to be slightly different, so you use a backslash before the command to run the program without the alias.
So for example, my grep is aliased to:
alias grep='grep --colour=auto -n'
So grep will always highlight results in colour and show a line-number. And very often when I'm grepping source code - I want to see the line numbers and have things coloured.
But in a shell script where I might be grepping for a line in a file that contains a certain keyword, so I can parse out a line of data - I don't want the line-number to be included in greps output - because it adds an extra, unwanted field to the start of that line of data. So I will use
\grep
to escape the alias for grep. That way my script can find lines in a data file that contain a keyword and then cleanly parse the rest of the data in that line.