Programming and Scripting :: Embedding Commands



It's pretty easy.  In your text editor, start the file with:

#!/bin/bash

then add whatever you want on the next lines:

#!/bin/bash
mkdir <...> or whatever


save it and make it executable with chmod and you should be good to go.  Have fun!

An other example:

#!/bin/sh
killall -9 wmclockmon
/cdrom/keep/dockable/usr/bin/wmclockmon -tm 1 &
#this batchfile restart wmclockmon

this file (when executed) kills a process (an other executed file) with the name: wmclockmon (a clock ). After that it start the clock

-When there's a # in front of a line, everything in that line is NOT executed
-When there's a & at the end of a line, the command's in that line are executed AND the process moves on to the next line (doesn't wait for the commands in that line to end)
-When there's not a & at the end of the line, the process waits until every command is ready with it's task.
-the first line of a "batch-file" is: #!/bin/sh


Just an example, i hope i got it all right (i am learning just like you)

BASH scripts are a million times more powerful than old DOS BAT files.

If you want to learn more about BASH, here is the place:

http://www.tldp.org/LDP/abs/html/

Hi,

Ok, I created an executable bash file:

#!/bin/bash
mydsl-load /opt/circuslinux.dsl

I saved it as /opt/circus

Typing /opt/circus in a terminal window will add the circus game to mydsl in the context menu, and clicking on it will open and run the game.

However, adding [exec] (Circus) {/opt/circus} to  a submenu in the context menu file still does nothing when I click on that menu item.

Do I have to "call" the bash file somehow in my menu file for it to work?

There is a reason why I'm doing all this, so any help will be appreciated  :)

Aussie

Quote (Aussie @ Sep. 23 2005,13:17)
#!/bin/bash
mydsl-load /opt/circuslinux.dsl

Success!

The mydsl-load command loads the game into /usr/games/

I then have to "call" the game by adding an extra line:

/usr/games/circuslinux

I also have to leave the "&" option out of the first command, to give the system time to load the game before "calling" it.

So my bash file is:

#!/bin/bash
mydsl-load /opt/circuslinux.dsl
/usr/games/circuslinux

Now the link in the context menu works, and the game starts automatically (without adding a mydsl entry in the context menu).

The reason I wanted to do this is to only load applications when I need them, rather than have mydsl load everything at start-up. This saves time and resources.

If I can do the same with other apps such as Office, I assume I'm going to have a very fast and versatile OS that is bulletproof - since it's a frugal install.

We shall see  :)

Aussie

Next Page...
original here.