So, here's the deal... I was attempting to type this:
and somehow I typed this instead:
I accidentally typed "space-asterisk" on the second prompt. This apparently caused Bash to attempt to run the first file in the pwd, which happened to have *something* that spawned a load of processes and killed my server (a VPS with fixed process count). I've never seen this. Can anyone explain the "space-asterisk" phenomenon? It seems like the sort of thing that's a subset of a bigger form of command line trickery and awesomeness, but I can't seem to put together the right search terms to get Dr. Google to explain it to me...
When you execute the command
the asterisk is first expanded to all files and (and other items) in the current directory. So for example if the directory contains the files
then the command becomes:
What happened in your case was that the first command failed and then the second command was executed, which expanded to:
where 'first' is the command and 'second' 'third' are the parameters.
Normally there is a safeguard and 'first' would not be executed since a command is only recognised as a command by the OS if it either is called as <path>/command (e.g. ./first) or it is located in a directory that is part of you search path (the variable "PATH").
My guess would be that there was either:
- a '.' in your search path ( which would illustrate one of the biggest dangers of this practice ), or
- the current directory happened to be in the PATH variable, or
- the name of command happened to be the same as a command in one of the directories in the PATH variable.
For the command to wreak this much havoc you were probably executing the command as root?
S.
Last edited by Scrutinizer; 08-29-2009 at 06:16 AM..
OS : RHEL 6.5
Shell : Bash
With the following bash shell script, when I enter password, it won't be printed in the screen.
But, I would like Asterisk character to be printed instead of the real characters. Any idea how ?
$ cat pass.sh
echo "Enter the username"
read username
echo... (3 Replies)
Hello,
I am trying to save in a file a single "*" but its not working... look what i am doing...
FILE="/home/teste/a.txt"
...BEGIN...
ASTERISK="*"
echo "STRING $ASTERISK STRING" >> $FILE
...END...
when i do it, the result is a list of all files of the current... (4 Replies)
hey champs,
I have a process running.......i have to catch/trap the signal when the process is being interupted/killed (kill -9 pid) option......
how can i achieve the same thru my process........
let my process is a.sh and it supposed to take 13 mins to complete, but due to some problem ,... (15 Replies)