pld@hpfcso.HP.COM (Paul Dineen) (10/26/89)
When I pipe to an alias in a ksh script, the alias definition is always unknown. For example: $ alias bigfiles='sort -r +4' $ cat >script #!/bin/ksh ll | bigfiles ^D $ script ./script[2]: bigfiles: not found When the line "ll | bigfiles" is executed from the keyboard, there is no problem. Wha' happen? Thanks.
davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/26/89)
In article <7010003@hpfcso.HP.COM>, pld@hpfcso.HP.COM (Paul Dineen) writes: | When the line "ll | bigfiles" is executed from the keyboard, there is | no problem. | Wha' happen? Did you forget to export PATH? That would leave the script using the default. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon
cpcahil@virtech.uucp (Conor P. Cahill) (10/27/89)
In article <7010003@hpfcso.HP.COM>, pld@hpfcso.HP.COM (Paul Dineen) writes: > $ alias bigfiles='sort -r +4' > $ cat >script > #!/bin/ksh > ll | bigfiles > ^D > $ script > ./script[2]: bigfiles: not found > > When the line "ll | bigfiles" is executed from the keyboard, there is > no problem. Wha' happen? The alias is not exported to the sub-shell. To get the correct effect you can run: . script Or you can put the alias into your $ENV file so that the alias is scanned during the shell startup. Or (much preferred) you can change the shell so that it doesn't use the alias. Aliases are designed to ease typing, but since this is going into a script, you don't need to ease the typing. Using the alias will make the shell harder to decipher and unusable for anyone that does not have your identical environment. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+
tale@pawl.rpi.edu (David C Lawrence) (10/27/89)
In <7010003@hpfcso.HP.COM> pld@hpfcso.HP.COM (Paul Dineen) writes:
Paul> When I pipe to an alias in a ksh script, the alias definition
Paul> is always unknown. For example: [...deleted...]
Paul> When the line "ll | bigfiles" is executed from the keyboard,
Paul> there is no problem.
In <1487@crdos1.crd.ge.COM> davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr):
Bill> Did you forget to export PATH? That would leave the script
Bill> using the default.
The problem is not at all related to PATH. As with any shell that
allows aliasing and/or function definition, the aliases and functions
are not passed to children. Only variables exported to the environment
are directly availble. If he wants the bigfiles alias, he will have
to define it in the script, or source the script rather than execute it.
Dave
--
(setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/27/89)
In article <1989Oct26.200808.16725@rpi.edu>, tale@pawl.rpi.edu (David C Lawrence) writes: | The problem is not at all related to PATH. As with any shell that | allows aliasing and/or function definition, the aliases and functions | are not passed to children. You're right. I assumed the alias was in the $ENV file and that the problem was elsewhere. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon