Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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/"; }
    function jdm () { alias bdc="bdc --arc --delete --moves"; }

    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

    ok then

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

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

    Your code seems to work for me:
    # @(#) s1       Demonstrate functions.
    function jdw () { alias list=" echo ls /mnt/"; }
    function jdm () { alias bdc=" echo bdc --arc --delete --moves"; }
    echo " Activate the aliases."
    echo " Try the alias."
    which produces when run:
    % ./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 )

  4. $spacer_open

Posting Permissions

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