Exit shell script
I just entered the below script into my bash shell. Then, realized, I wanted 192.168.0..., and not 192.168.1. So, tried Ctrl-C, esc, etc, but I could not break out, and finally had to close the terminal. How does exit the shell script command? Thanks
Code:
for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done |
Better way to check whether hosts are up or not in subnet is by issuing
Code:
# nmap -sn 192.168.1.0/24 |
Thanks mddesai,
Yes, it is better. What about existing the shell script command? When I do cntr-c or esc, it just shows the escaped characters on the screen. I type exit, quit, etc, but I just see the words on the screen, but can't exit. |
Quote:
2. enter 'jobs' at command prompt to check job number 3. then, enter kill %<number> to kill the job permanently |
Thanks mddesai,
Worked perfect. What was the purpose between the percent sign? For instance, kill %1? |
Quote:
to check for both job number and PID, give 'jobs -l'. ex: kill %1 //kills process with job number 1 kill 4546 // kills process with PID 4546 Edit: For 'sure kill', you can give kill -9 4546 More: Job Control Commands |
Thanks mddesai,
kill 4546 didn't take care of it, but kill -9 4546 had the same effect as kill %1. Sorry for digressing, but tried to get more info about kill and tried kill -h, but no help page. |
Quote:
kill [signal] PID When no signal is explicitly included in the command, signal 15, named SIGTERM, is sent by default. Once the process receives the notice, a few different things can happen:
More: The 3 most important "kill" signals on the Linux/UNIX command line UNIX Kill Command Examples SIGTERM vs. SIGKILL |
The kill you're using is almost certainly the bash built-in. See the JOB CONTROL section of the man page for details on how to use it, and more.
Incidentally, there's very little need for seq these days, now that advanced shells like bash have brace expansions that accept ranges. The [url=http://wiki.bash-hackers.org/syntax/ccmd/c_for]c-style for loop[/code] is another common option. It's also recommended to use [[..]] for string/file tests, and ((..)) for numerical tests. Avoid using the old [..] test unless you specifically need POSIX-style portability. http://mywiki.wooledge.org/BashFAQ/031 http://mywiki.wooledge.org/ArithmeticExpression Or in this specific case you could also just test the exit code directly: Code:
for ip in 192.168.1.{1..254}; do |
All times are GMT -5. The time now is 05:46 AM. |