How to use an angle brackets in command line arguments?
Suppose the input is: filename -w <input.txt>
Here input.txt
is a second command line argument, and it is an input file to a program here input.txt must be enclosed by angle brackets( <input.txt>
) . But if I use angular brackets i m getting error. error is :
sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `demo -w '
Your question is not very clear. However, it seems to me a shell problem, not a Tcl one.
I suppose your filename
is the name of a Tcl executable script and you want to give it input.txt
as parameter.
But the angle brackets have special meaning to the shell. sh
interprets the <
as standard input redirecting, so it reads the content of input.txt
and passes it to filename
through the standard input channel.
Then, sh
interprets the >
as standard output redirecting, but after that there is no name to redirect the output to, so it gives you the error you see, because after >
you pressed the Return
key.
So, are you sure your script needs the filename surrounded by angle brackets? If so, escape the brackets, like
filename -w \<input.txt\>
Otherwise, try to completely remove the brackets and use
filename -w input.txt
I hope this helps.