LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-13-2004, 12:51 AM   #1
true_atlantis
Member
 
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 name@eminem.cs.colostate.edu:~/public_html

to like this

schoolcp *file

and it would just insert the variable... thanks
 
Old 04-13-2004, 01:25 AM   #2
AMMullan
Member
 
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 www.tldp.org)
 
Old 04-13-2004, 07:35 AM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Code:
#!/bin/bash
scp $1 name@eminem.cs.colostate.edu:~/public_html
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.
Code:
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.



Håkan
 
Old 04-13-2004, 02:55 PM   #4
nhs
Member
 
Registered: Aug 2003
Location: Edinburgh, Scotland
Distribution: Gentoo
Posts: 246

Rep: Reputation: 30
I would use
scp $@ name@eminem.cs.colostate.edu:~/public_html
instead to allow copying multiple files ($@ expands to all command line arguments)
 
Old 04-13-2004, 06:26 PM   #5
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

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


Håkan
 
  


Reply


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 06:32 PM
goto in linux shell script sabliny LinuxQuestions.org Member Intro 1 10-13-2005 04:00 PM
Linux can't find a shell script?? jt1020 Linux - General 4 04-27-2003 09:27 AM
how to run a shell script in Linux chandhru Linux - Newbie 2 09-27-2002 02:19 PM
linux shell script lightnup8 Linux - Newbie 4 01-27-2002 10:00 PM


All times are GMT -5. The time now is 01:04 PM.

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