Solved

Executing File Options

Posted on 2006-11-08
1
283 Views
Last Modified: 2010-04-21
Hey,

I would like to create an executable file with options, if I create a file named “dosomething” I would like to be able to pass in a parameter that would allow me to execute different things.  So… if I execute “./dosomething 1” I would be able to do different things.

… do some stuff for parameter of value 1
… do some stuff for parameter of value 2

How would I format the contents of the file? Is there an if statement or something of that kind?

Thanks,
Kate
0
Comment
Question by:kasiencja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
bira earned 500 total points
ID: 17900438
yes, you can use case inside, as below


create the script dosomething with this contents:

case "$1" in
 1 ) echo "do option one"
       exit ;;
 2 ) echo "do option two"
       exit ;;
esac

chmod it 777 and call it:

 ./dosomething  <option>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question