Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Knoppix Help Forum > script will not allow functions to work

Forgot Password?
 Knoppix Help Forum   For all discussions about Knoppix, the Linux "Live CD" that lets you run Linux without needing to install on your hard drive.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 11-20-2006   #1 (permalink)
Just Joined!
 
Join Date: Nov 2006
Posts: 79
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.
jwmw1023 is offline  


Reply With Quote
Old 11-27-2006   #2 (permalink)
Just Joined!
 
Join Date: Nov 2006
Posts: 79
ok then

no takers? well, can someone write a script that odes these things?
jwmw1023 is offline   Reply With Quote
Old 11-27-2006   #3 (permalink)
drl
Linux Engineer
 
drl's Avatar
 
Join Date: Apr 2006
Location: Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
Posts: 817
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 )
drl is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 06:36 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2