Re: Why is this not working?

Jens.Toerring_at_physik.fu-berlin.de
Date: 05/28/04

  • Next message: Lekeas GK: "Re: Why is this not working?"
    Date: 27 May 2004 22:35:50 GMT
    
    

    Barry Margolin <barmar@alum.mit.edu> wrote:
    > In article <Pine.GSO.4.58.0405272058001.9008@vega.soi.city.ac.uk>,
    > Lekeas GK <cj571@soi.city.ac.uk> wrote:

    >> >> Hi All,
    >> >>
    >> >> I am trying to create a script which would look like the which command
    >> >> under tcsh. I wrote the following script:
    >> >>
    >> >> #! /usr/bin/bash
    >> >> if ! `alias $1`; then
    >> >> echo "$1 is aliased to " `alias $1|cut -d\' -f2`
    >> >> fi
    >> >>
    >> >> However, when I execute it I get touch is aliased to ( which is not
    >> >> true, as I have created an alias for touch).
    >> >
    >> > Aliases are not exported.
    >>
    >> What do you mean aliases are not exported? From where to where? I only
    >> want alias $1|cut -d\' -f2 to run - as it is within backquotes - and
    >> produce /usr/bin/touch. However, it is not producing anything and I am
    >> very curious why this is happening.

    > Aliases are not exported from your login shell to the shell process that
    > is executing the script. ~/.bashrc is only executed by default in
    > interactive shell processes, and the script is being run by a
    > non-interactive shell.

    So you might use

    #! /usr/bin/bash -l
    if [ -n "`alias $1 2>/dev/null`" ]; then
        echo "$1 is aliased to " `alias $1 | cut -d\' -f2`
    fi
                                   Regards, Jens

    -- 
      \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
       \__________________________  http://www.toerring.de
    

  • Next message: Lekeas GK: "Re: Why is this not working?"

    Relevant Pages

    • Re: Why is this not working?
      ... >> Aliases are not exported. ... Aliases are not exported from your login shell to the shell process that ... is executing the script. ...
      (comp.unix.questions)
    • Jumpstart: syntax error and trying to load from /cdrom media, which disk to use for Solaris 8 image
      ... I'm not sure if I need to use that disk or the Solaris 8 Installation ... Using RPC Bootparams for network configuration information. ... Using finish script: diag_drv.fin ... Executing JumpStart preinstall phase... ...
      (SunManagers)
    • Re: understanding lambda
      ... All functions in the script are created when the script is parsed. ... A lambda function is created when the script is executing - and is not created unless that statement is executed. ... a new solid -- say, a cylinder, I would take two steps: ...
      (alt.php)
    • QUESTION: shared libraries
      ... how would I create a package easy-to-install for a new user? ... we could use a script to install the package. ... I have seen some scripts executing from a ... Gouvernement du Canada / Government of Canada ...
      (comp.os.linux.development.apps)
    • QUESTION: shared libraries
      ... how would I create a package easy-to-install for a new user? ... we could use a script to install the package. ... takes root privileges to do so. ... I have seen some scripts executing from a ...
      (comp.os.linux.development.system)