Create and run a bash script
I want to create a shell script to run a few commands as opposed to having to enter them every time I want to do something.
Essentially it's about 6 commands that unloads a module and loads another for my wireless card and puts in a few settings. So, I know the commands, but I don't know how to create the shell script and run it. I know you do it in a text editor, just not sure what to save it as and how to run it when I want to. If you could point me to a how-to or give me some pointers, I'd appreciate it. Thanks |
Advanced Bash Scripting Guide This has just about everything that you will ever need to know about BASH scripting, as well as a lot of examples.
|
That's a bit short plus the ABS might seem a bit intimidating to firsttimers. Basically a script contains the commands you run in your shell but with a starting line that reads "#!/path/shellname" and a ending line that reads "exit 0" (if you conform to standards) and some "basic logic" to deal with situations. If it's an initscript (you might call Wireless a networking subservice), things differ per distribution (please fill in your profile details) but at the same time you'll have the examples right there. Your basic Bash scripting guides are:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html http://www.tldp.org/LDP/Bash-Beginne...tml/index.html http://www.tldp.org/LDP/abs/html/ # this one not being that basic, OK. Else just post your distro name and the commands. |
just put in a file,
edit arbitrary_name.sh (the #! line must be the first line) Code:
#!/bin/bash then run it.. ./arbitrary_name.sh |
I always recommend linuxcommand.org as a beginning-level shell/scripting tutorial. It's very easy to follow and provides a good grounding in the basics.
|
Thanks for the help, I figured it out and couldn't post back fast enough. lol.
As always, you guys are a bunch of help. Brandon |
Quote:
|
Personally I prefer
chmod u+x arbitrary_name.sh no need to give group/others execute perm (unless there really is) |
Quote:
Code:
#!/bin/sh |
Actually, my point was you should only grant perms to those who need them, so normally only the owner needs eg 'rwx', not 'group' or 'others'.
ie rwx------ If you need to share the functionality with your group, but not editing, then rwxr-x--- too many people just go chmod +x which allows user,group and others aka world(!) execute perms. Not a good habit to get into... |
All times are GMT -5. The time now is 07:29 AM. |