Im doing this that works fine
utnso@utnso-vm:~$ read command
ps -fea
utnso@utnso-vm:~$ $command
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 23:34 ? 00:00:02 /sbin/init
root 2 0 0 23:34 ? 00:00:00 [kthreadd]
root 3 2 0 23:34 ? 00:00:00 [ksoftirqd/0]
...
But when trying to run this command it fails…
utnso@utnso-vm:~$ read command
ps -fea | grep bash
utnso@utnso-vm:~$ $command
ERROR: Garbage option.
********* simple selection ********* ********* selection by list *********
-A all processes -C by command name
-N negate selection -G by real group ID (supports names)
-a all w/ tty except session leaders -U by real user ID (supports names)
-d all except session leaders -g by session OR by effective group name
-e all processes -p by process ID
T all processes on this terminal -s processes in the sessions given
...
...
...
...
********* misc options *********
-V,V show version L list format codes f ASCII art forest
-m,m,-L,-T,H threads S children in sum -y change -l format
-M,Z security data c true command name -c scheduling class
-w,w wide output n numeric WCHAN,UID -H process hierarchy
Does anybody know whats going on??
Thanx in advanced!
When your command line consists of a single parameter to be expanded, such as
bash does the following:
That’s it. No further parsing of the expansion is done to process the result as any type of compound command or variable assignment or redirection.
Anything more complicated needs to be passed to the the
evalcommand, but only if you fully understand howevalworks and know the security implications of evaluating an arbitrary string. In my opinion,evalshould be considered a tool of last resort, not a convenience.