Re: bash script command
yes of course why i m not using an external script for each compilation if [ $? != 0 ] then #insert commands (or better, an external script) to build glibc ## if you use an external script, then do not use any exit ## values so that the last command in the external script ## determines the return value of the script itself. This so ## that you can check to see if it was successful or not like so: if [ $? == 0 ] then echo glibc $LOGFILE else echo Build failed while building glibc! exit 1 fi fi thanx for the suggestion btw, i m not using kernel-vanilla for my lfs/blfs, but i m use kernel-source package from opensuse 11 (my host system, cause i think it have better hardware support) however the im not using .config from suse because it not bootable (kernel panic) so i using .config from vectorlinux and it works (bootable) are this is legal? note: i appreciate to all of you tht involved in this project at least i can build my own distro without remastering the exist one and you know what i already have KDE in my LFS computer is never be same if you are not a kernel-hacker but you could build your own system i love tux sorry for for the english -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
Re: bash script command
On Sat, Aug 30, 2008 at 1:19 AM, arsyante [EMAIL PROTECTED] wrote: btw, i m not using kernel-vanilla for my lfs/blfs, but i m use kernel-source package from opensuse 11 (my host system, cause i think it have better hardware support) I would use the vanilla kernel unless you know exactly what patches are in opensuse's kernel and you want to keep track of them. Of course, if you know that there is some driver that opensuse has added that's not in the vanilla kernel, then I suppose you can try to use the .src.rpm. however the im not using .config from suse because it not bootable (kernel panic) so i using .config from vectorlinux and it works (bootable) are this is legal? Any .config you want to use is perfectly legal (the kernel source will add/remove any config settings it needs with the defaults). The reason your suse config doesn't work is because it expects to use an initramfs to load your the kernel modules for your hard drive. You'll need to build those into the kernel unless you want to make an initramfs, too. If you have no experience with an initramfs, I'd suggest just building stuff into the kernel. -- Dan -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
Re: bash script command
actually i trying to make script for building LFS i ve tries jhlfs, i like it but i want to use selfmade scripr == #!/bin/bash -e done='cat done.log` sources=/mnt/lfs/sources cd $sources tar xvf foo.tar.gz cd foo ./configure --prefix=/tools make make install echo foo done.log cd $sources tar xvf bar.tar.gz cd bar ./configure --prefix=/tools make make install echo bar done.log === my plan is the script read done.log 'n assign the value to $done just assuming that bash script have jump and label so the script became #!/bin/bash -e done='cat done.log` sources=/mnt/lfs/sources goto $done :start cd $sources tar xvf foo.tar.gz cd foo ./configure --prefix=/tools make make install echo foo done.log :foo cd $sources tar xvf bar.tar.gz cd bar ./configure --prefix=/tools make make install echo bar done.log :bar cd $sources tar xvf glibc.tar.gz cd glibc ./configure --prefix=/tools make make install echo glibc done.log == so if we already install foo.tar.gz and when compile bar.tar.gz it's interupted (e.g segmentation fault) so if we execut the script again the script not start from begining but from :foo (compiling bar.tar.gz) and continue to the rest but this is just simple script before we entering the chroot and when we entering chroot we use another script any suggestion?? btw, is there any hint to build lfs with reiser4 as root partition, is it true that reiser4 is the fastest file system and how doyou think about reiser4 stability, and its future sorry for my bad english -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
Re: bash script command
arsyante wrote: actually i trying to make script for building LFS i ve tries jhlfs, i like it but i want to use selfmade scripr This is kind of like learning to walk before you crawl. Of course, it is possible, but it's going to be difficult and you will learn a lot as you go through it, prompting multiple rewrites I'm sure. You probably need to get used to using numeric return values. Look at the following for example: [EMAIL PROTECTED] /]# cd ~ [EMAIL PROTECTED] ~]# mkdir test [EMAIL PROTECTED] ~]# echo $? 0 [EMAIL PROTECTED] ~]# mkdir test mkdir: cannot create directory `test': File exists [EMAIL PROTECTED] ~]# echo $? 1 [EMAIL PROTECTED] ~]# The same thing applies to every program, 0 is successful, anything else is an exception (either it failed or it completed but not as expected). This concept is identical to the use of %errorlevel% in DOS. Next on your list of commands to learn is if and while commands. They usually utilize the command 'test'. The commands '[' and 'test' are synonymous (however, when using bash, '[' is a built-in command and must be closed with a matching ']'). Using the same commands as the example above. The first run of this program will return 0 and print Successful! to the screen. Any subsequent runs will print Unsuccessful! but will still return 0 as the last command (the echo command) completed successfully. #!/bin/bash # Begin /home/dj/bin/example_testcase.sh cd ~ mkdir test 21 /dev/null if [ $? != 0 ] then echo Unsuccessful! else echo Successful! fi # End /home/dj/bin/example_testcase.sh = my plan is the script read done.log 'n assign the value to $done just assuming that bash script have jump and label so the script became Snip == so if we already install foo.tar.gz and when compile bar.tar.gz it's interupted (e.g segmentation fault) so if we execut the script again the script not start from begining but from :foo (compiling bar.tar.gz) and continue to the rest but this is just simple script before we entering the chroot and when we entering chroot we use another script any suggestion?? === LOGFILE=/media/lfs/done.log # SNIP ## Build GlibC grep glibc $LOGFILE if [ $? != 0 ] then #insert commands (or better, an external script) to build glibc ## if you use an external script, then do not use any exit ## values so that the last command in the external script ## determines the return value of the script itself. This so ## that you can check to see if it was successful or not like so: if [ $? == 0 ] then echo glibc $LOGFILE else echo Build failed while building glibc! exit 1 fi fi === Finally, coding style...the above is sloppy IMO, but it works. It was done that way for you to only see the necessary parts. I personally quote everything, and use {} for clarity. ex: 'echo ${?}' and 'echo $?' are identical, but when running strings together, the first example is much easier to read when looking at a really long script. Also, one other trick: '' at the end of a command is a shorter test case...if the command fails, then the next command in line is not run (and '' is cumulative..all lines are skipped until _after_ one is not terminated with ''). The functions file in the LFS bootscripts make use of many of the shell tricks so you might like to look at those for some ideas. btw, is there any hint to build lfs with reiser4 as root partition, is it true that reiser4 is the fastest file system and how doyou think about reiser4 stability, and its future sorry for my bad english Sorry, I haven't tried it and likely will not. I'm not sure exactly how stable it is yet, but Reiser4 is still pretty young in comparison and the original developer is no longer able to work on it due to loosing his marbles and being incarcerated as a result. http://www.boingboing.net/2008/07/07/programmer-and-murde.html -- DJ Lucas -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
bash script command
i m sorry maybe this is irrelevant with this milis but i new in linux in past i ussualy use batch file now i try to use shell script i got problem in batch file i ussualy use @echo off some command some command goto end :end some command --- what is replacement goto end and :end in bash script i've tried function(), but that is not excatly what i want i need command that jump to another part of that script sorry for my bad english (i am indonesian) and thanx for your attention -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
Re: bash script command
On Thu, Aug 28, 2008 at 10:39 AM, arsyante [EMAIL PROTECTED] wrote: i m sorry maybe this is irrelevant with this milis but i new in linux in past i ussualy use batch file now i try to use shell script i got problem in batch file i ussualy use @echo off some command some command goto end :end some command --- what is replacement goto end and :end in bash script i've tried function(), but that is not excatly what i want i need command that jump to another part of that script There are no labels and jumps in shell. The best you can do is use conditionals. foo() { commands } bar() { commands } if [ $somecondition = 1 ]; then foo else bar fi Here is some good documentation on bash (which is probably the shell you're using): http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html http://tldp.org/LDP/abs/html/ -- Dan -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
Re: bash script command
arsyante wrote: what is replacement goto end and :end in bash script i've tried function(), but that is not excatly what i want i need command that jump to another part of that script As Dan already pointed out, there are no direct replacements for labels and goto. However, I think that you will find functions and conditional statements much more powerful than the goto command once you use them a few times. Here is your example.bat in example.sh: = #!/bin/sh # Begin /home/dj/bin/example.sh # this is a function for the label you used above end(){ some ending command # the exit command takes an optional return # value to pass back to the shell errorlevel # in DOS is $? in shell (the return vlaue) exit 0 } # This is where your script actually starts some command some command # if the previous command was successful then end # or continue on to the next command if [ $? == 0 ] then end fi another command another command end # End /home/dj/bin/example.sh = Feel free to throw a couple more small examples this way if you need more help with it. -- DJ Lucas -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page