In recall for nostalgic feelings, I've remembered the .bat files on DOS. :)
Here's the thing: Each time I need to generate a documentation for a given web application I have to:
sudo phpdoc -o HTML:frames:earthli -d public_html/yoursite.dev/application/ -t public_html/yoursite.dev/docs/
is there a way to make a shortcut to the above, so that, we can type only:
sudo generateDoc.sh -a yoursite.dev
or even better:
sudo generateDoc.sh -theVariableThatNeedsTobeChangedOnBashHere
So that, if we have yoursite.dev passed on the command line, the bash will have yoursite.dev, if we write yoursite2.dev then, the bash would have yoursite2.dev and so on...
Any clue?
Thanks a lot.
Try this:
Call it as
sudo ./script.sh yoursite
.You can also place this function in your .bashrc:
then
Here's an example script I wrote. The
$*
means "all the arguments passed". Importantly, they're in quotes because otherwise white space would break the command. Quodlibet is a sweet music library/player, btw.Like Fido said, don't forget to set the file as executable with
chmod +x programName
.Something you might consider is making a
bin
directory in your home folder and adding it to your$PATH
. Then you can call the command no matter what folder you're in. I have this line in my .bashrc:PATH=$HOME/bin:$PATH
. If you don't do this, you have use an absolute or relative path when you call your script, ie:I highly recommend Grymoire's guide to SH scripting. What you're needing to do is use the shell's Positional Parameters to take arguments and insert them into your command. There's also TLDP's more in depth treatment of BASH's Positional Parameters. I'd start with Grymoire's, and then read through TLDP when you're ready for a more advanced treatment of the subject.
Open your favorite text editor, paste the following:
and save it as (in this case) 'generateDoc.sh'. The next thing to do is to give execution rights to your file, so open a terminal, and run:
$ chmod +x generateDoc.sh
Now all you need to do is call the file:
$ ./generateDoc.sh yoursite.dev
there's no need forsudo
here, because it's already inside the sh file.Hope this helps!