Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-12-2004, 11:51 PM   #1
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
linux shell script

is there a tutorial on how to make your own commands for shell scripts... for example, i want to make a command 'camera' that will ask for su password then mount my digital camera (/dev/sda1) to a specific point (/mnt/camera) and another one that will copy files from my computer to my school account using scp, basically transfering this

scp *file

to like this

schoolcp *file

and it would just insert the variable... thanks
Old 04-13-2004, 12:25 AM   #2
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
I would makea seperate shell script called camera and have it do wht you want camera to do - there (as far as I know) is no actual way to unless you want to do some programming

It should be easy enough to do tho... Look up on Google for bash shel scripting tutorials - there are heaps around (including a very good one at
Old 04-13-2004, 06:35 AM   #3
Senior Member
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
scp $1
Save as "upload" or something and drop it in your personal bin directory (~/.bin if you have it set up) and make it executable. Call it as upload filename, $1 always means "the first argument to this script" so the arguement you type with replace $1 on the scp command in the script.

As for the other script, I think an expect script would do better than a shell script considering the su part. But on the other hand you could make an alias, that would probably be even better.
alias cam='su -c "mount /dev/sda1 /mnt/camera"'
Put that in your ~/.bashrc, ~/.bash_profile or something. Or just type it at the prompt. When you type cam you will be asked for the root password and then the camera will be mounted.

Old 04-13-2004, 01:55 PM   #4
Registered: Aug 2003
Location: Edinburgh, Scotland
Distribution: Gentoo
Posts: 246

Rep: Reputation: 30
I would use
scp $@
instead to allow copying multiple files ($@ expands to all command line arguments)
Old 04-13-2004, 05:26 PM   #5
Senior Member
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Nice, I didn't know that. Thanks.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
goto in linux shell script sabliny Member Intro 1 10-13-2005 03:00 PM
Linux can't find a shell script?? jt1020 Linux - General 4 04-27-2003 08:27 AM
how to run a shell script in Linux chandhru Linux - Newbie 2 09-27-2002 01:19 PM
linux shell script lightnup8 Linux - Newbie 4 01-27-2002 09:00 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration