View Full Version : Linux .BAT (shell) files, tiny problem
SystemJay
04-19-2010, 01:57 PM
Hi,
Im quite new to shell scripts, I just need to do one small thing with it.
Id need my script to run:
module load xxxx
module load yyyy
python runPythonFile1.py argument1
python runPythonFile2.py argument2
And thats it, but I cant seem to be able to do it correctly with google-help.
What I have tried last and epicly failed is:
#!/bin/bash
clear
echo `module load xxxx`
echo `module load yyyy`
echo `python runPythonFile1.py argument1`
echo `python runPythonFile2.py argument2`
Thank you for your time. :thumbsup:
tomws
04-19-2010, 02:29 PM
You're just telling it to echo. That doesn't run a command - it just prints to screen. To run your command, actually run your command. For example:
#!/bin/bash
python runPythonFile1.py argument1
Part of your Google problem may be that you're trying to search for the Windows term ".bat" for batch files. Search instead for "bash shell scripting", perhaps. Here's an old link (http://www.faqs.org/docs/Linux-HOWTO/Bash-Prog-Intro-HOWTO.html) I dug out from my bookmarks.
SystemJay
04-19-2010, 03:40 PM
transfer.sh: line 3: module: command not found
transfer.sh: line 4: module: command not found
...
and rest is errors cause the modules arent loaded.
line 3 and 4 are
#!/bin/bash
#Load right modules for server
module load xxxx
module load yyyy
So aint working like that straight, something is missing (of course :P)
ran the file like this: sh transfer.sh
I tried to google and found earlier the link you posted as well,
but nothing speaks of how to run module commands in the script.
It runs correctly the python commands cause they start but fail
to the fact that the modules arent loaded.
(i mean earlier before i tried that stupid echo-test :P)
EDIT:
http://stackoverflow.com/questions/1127383/how-to-issue-module-load-in-a-shell-or-perl-script-i-e-non-interactively
Is the link that had the most closest idea for an aswer but...
: invalid shell option name expand_aliases or
: No such file or directoryrofile
errors came for those solutions.
tomws
04-19-2010, 03:43 PM
That simply means what it says: 'module' is a command not available to Bash on your server. Bash is great, but it still can't execute commands that don't exist. :D
What are you trying to do?
SystemJay
04-19-2010, 03:58 PM
Yeah thought so...
Im trying to do so that users dont have to type those lines manually each time they want to run the combination.
So when a user wants to use the scripts I made, instead of writing:
module load xxx
module load yyy
python script.py arg1
python script2.py arg2
Id like them to write just
sh runTheWholeThingWithOneCommand.sh
and be happy with it :P Because only thing they need to do with the command
line is to write those 4 lines, so I thought to make it even easier for them
to just write 1 line, but it seems my own noobness with linux-stuff is getting
the better of me :P
tomws
04-19-2010, 05:02 PM
Did you check the comments at that Stack Overflow link? Next-to-last suggests a "-l" (I think) argument to the shebang line.
SystemJay
04-19-2010, 09:00 PM
I thank you for your efforts.
I decided to give up with this idea, and instead do it also with python.
The thumbs up for this approach is that I can make arguments dynamic easly.
Cheers! :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.