On Fri, Dec 02, 2011 at 08:26:28AM -0600, Peng Yu wrote: > When I call, > > execute.sh ls > /tmp/tmp.txt > > I want it actually to do > > echo "ls > /tmp/tmp.txt" > ls > /tmp/tmp.txt
That is impossible. The redirection, being unquoted, is performed by the shell where you are actually typing that. If you want the > symbol to be passed to the script as (part of) an argument, then it must be quoted, as in your second example: > execute.sh "ls > /tmp/tmp.txt" THAT will work. But why are you writing a script to read a shell command and then execute it? There is already a program that reads shell commands and then executes them. It's called bash.