[svlug] cshell question
D. Dante Lorenso
dante at lorenso.com
Tue Sep 8 18:42:40 PDT 1998
On Tue, Sep 08, 1998 at 02:27:33PM -0700, Harry Mason wrote:
> I'm using an old book called the c-shell field guide. It uses
> a command script of the following:
>
> echo -n "Input your terminal type: "
> setenv TERM `gets`
>
> Well, gets isn't found, so I used
> setenv TERM `$<` and entered
> ibm3270, but it said ibm3270: command not found.
> I guess at the time the book was written, the ` symbols
> would capture the results of one command into the word list
> for another command. Is this a typo? Did it ever work?
> And yet set d = `date` works fine. Why is ibm3270 or for that
> matter in other thing interpreted as a command instead of as
> a word list in setenv TERM `$<` ?
In the c-shell, if you put a command in backticks ----> `
it will execute the command first and use the output of the
command as the actual data being typed. Hence 'Dog' (in
quotes) is not the same as `Dog` (in backticks).
[dante]/home/dante> echo 'Dog'
Dog
[dante]/home/dante> echo `Dog`
Dog: Command not found.
In the second example, the shell attempts to execute the command
"Dog" just before executing "echo"...in the first example, the
WORD "Dog" was used as an argument to the echo command.
This is a neat trick if you want to do something like this:
[dante]/home/dante> echo `echo hello | sed -e 's/lo/p/'`
help
Where, the first echo command prints "hello" to sed which replaces
the "lo" with "p" and sents that as an argument to the other "echo"
command.
In your example above, the $< was read in and the results of that
string were treated as a command to execute. Perhaps by changing
the quotes, you might modify its behavior correctly.
Dante
--
------
D. Dante Lorenso
dante at lorenso.com
http://www.lorenso.com/dante
--
echo "unsubscribe svlug" | mail majordomo at svlug.org
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to unsubscribe
More information about the svlug
mailing list