Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi everyone, I have very little experience with scripting and linux and i don't how to go about solving this problem.
Create a shell script, driver.sh, that can execute a program with a specific set or parameters an arbitrary number of times. The program name, the parameters and the number of times should be passed to the script. The output from each run should be stored in a reasonable way (so that it is easy to access, analyze and plot it). Please note that you do not need to process the output, only make sure it is stored in a file. The script should take the following parameters: driver.sh [number of times] [program to run] [arguments to the program]
Yes, it's part of my assignment and i'm not asking for solution, just trying to understand the problem domain.. I know there will be some sort of loop to run the program an arbitrary number of times but am i suppose to write a program that accepts many parameters and run it multiple times?
This is what i've done so far..
for i in {1..5} // say i want to run it 5 times
do
......
done
I know where to find links to books about shell scripting if i wanted. I just needed someone to tell me, this is what i was asked to do, this is how is how to go about it...
Do they give you a book to read, or a class to attend, to go along with this assignment?
try googling "bash script parameters", google is your friend...
This assignment is just to get us familiar with scripting. The course is mainly based on multithreaded programming and it's funny how people here keep telling me to google and stuff. Don't see the point of the forum then.
Can't seem to find any tip online on the use of "$@" can you explain more...
This is what ive done so far
#!/bin/bash
for ((i=5; i>0; i--))
do
java Driver 1000 >> output.dat
done
exit 0
run the program 5 times, Driver is the name of the program and i explicitly passed it 1000 as an argument.
So let us suppose your script is called driver.sh. You are running it with all the arguments etc. Why don't you add a "echo $@" to the second line and see what happens. If you don't know what is the purpose of "$", then I'm afraid you need to do a bit of reading. Unix is all about experimenting and "echo" is your friend for shell script debugging.
I know what $@ is but can't seem to figure out its use in my script. I think maybe i'm not understanding the question being asked. To my understanding, i'm suppose to provide some arguments say 1000, 2000, 3000 stating them explicitly in the script... and for each arg, the program runs it 5 times and at the same time generating all the argument in the same output.dat file ??
You will write a script, S.
That script will execute a program, P.
Program P needs a bunch of arguments, x1, x2, ... xm.
Program P (with the m parameters) will be executed N times.
Each execution of program P should store its output in a reasonable way.
The last sentence in the original post gives you the name of the script and the sequence in which the other goodies should be given.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.