Find the answer to your Linux question:
Results 1 to 3 of 3
hello, i am writing a small script to take care of some things when booting my knoppix disk. i cannot get any functions or aliases to work. i am sending ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    90

    script will not allow functions to work


    hello, i am writing a small script to take care of some things when booting my knoppix disk. i cannot get any functions or aliases to work. i am sending these commands in the script:

    function jdw () { alias list="ls /mnt/"; }
    jdw
    function jdm () { alias bdc="bdc --arc --delete --moves"; }
    jdm

    i start the script with #!/bin/bash
    but have tried #!/bin/sh
    also i have tried just the alias but with the shopt -s expand_aliases command and it also fails. everything else in the script works.

  2. #2
    Just Joined!
    Join Date
    Nov 2006
    Posts
    90

    ok then

    no takers? well, can someone write a script that odes these things?

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,283
    Hi.

    Your code seems to work for me:
    Code:
    #!/bin/sh
    
    # @(#) s1       Demonstrate functions.
    
    function jdw () { alias list=" echo ls /mnt/"; }
    function jdm () { alias bdc=" echo bdc --arc --delete --moves"; }
    
    echo " Activate the aliases."
    jdw
    jdm
    
    echo
    echo " Try the alias."
    list
    bdc
    which produces when run:
    Code:
    % ./s1
     Activate the aliases.
    
     Try the alias.
    ls /mnt/
    bdc --arc --delete --moves
    Note that I added an echo so that you know the alias definition has worked ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •