LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Are linux scripts just as simple as dos batch files? (https://www.linuxquestions.org/questions/linux-general-1/are-linux-scripts-just-as-simple-as-dos-batch-files-26220/)

neeyo 07-20-2002 07:21 PM

Are linux scripts just as simple as dos batch files?
 
I just did a new Gentoo installation, and it will take a while to update everything and compile/install X+kde, so I want them both going overnight.

Can I just create a file that says:

emerge world --update
emerge kde

and save it as something like night.sh and then run it? Or what else would I have to do?

sarin 07-20-2002 07:50 PM

I am not sure about the commands that you gave. But if they exist and there in your path. you can surely do it. ( I don't find "emerge" in my path. But I use RH7.2 ). You might do chmod u+rx night.sh and to run it
type
./night.sh
from the directory in which it is stored. If you want, create a "bin" directory in your home and add to your path so that later you can put such stuff there and it will be easier to use these scripts later ( This is only optional. Forget it if you don't understand it now )
And about bash script, I should say, I never found the greek or latin in autoexec that enlightening :-) .
--Sarin

Thymox 07-20-2002 08:23 PM

Ok, shell scripts (bash/sh/csh/whateversh) are similar in principle to the ol' DOS .bat files, and in many ways, they similar in implementation aswell. The beauty about scripting, though, is that if you should so choose, they can be much more complex, even becoming a complete program!

I'm assuming that the 'emerge' command is a gentoo specific command. If those are the only two commands you will want to use, and you're certain that they will finish fine, then you need not even write a script.

If you have emerge world --update && emerge kde as a single command, then the first will run, and when it has finished, the second will run. I suppose the advantage of having the two commands run from a script is that you could then run the script with ./night.sh & and it wouldn't tie-up your terminal, so you could get on with something else in the mean time.

Hope this helps.

RefriedBean 07-21-2002 12:02 AM

Hi!

Well, your script should look something like this

Code:

#!/bin/bash
emerge world --update
emerge kde

And then, don't forget to make it executable
chmod +x night.sh

Good Luck!
RefriedBean

almostlucky 07-21-2002 11:42 AM

if it is a new gentoo installation, everyting will be up to date. So you probably wont need to update world.
You can also emerge multiple packages in one command, ie

emerge kde mozilla sylpheed waimea

that will probably take care of anything you need that the script was going to do. Be sure to check out all the help gentoo has to offer. They have great help on mailing lists, their forum and the irc channel. check it all out at the gentoo page


All times are GMT -5. The time now is 10:47 PM.