[WBEL-users] Writing a script in bash

Jean Lee jean.lee at free.fr
Wed May 25 06:54:46 CDT 2005


Great,

That works fine. Thanks you for your help

For my application it's more accurate to use something like :

if (mount /dev/sda1)
then
    Backup
else
    exit 1
fi

But it si good to know this and I will explore the link given by Erik.

Jean

Fernando Apesteguía wrote:

>There are three channels in UNIX shells: standard input, standard
>output and standard error output.
>
>Messages you obtain when USB device is not present are sent to the
>error output (that usually is connected to the standar output, but
>there are 2 different channels).
>
>So if you want to trace error messages try:
>
>./backup 2>> /var/log/backup.log
>
>Channel 2 is used for error output.
>So error will send to backup.log and other messages like:
>
>echo backup created successfully!! 
>
>will be displayed in the console.
>
>Best regards!!!
>
>On 5/24/05, Jean Lee <jean.lee at free.fr> wrote:
>  
>
>>Hello,
>>
>>I am not sure this is the correct list to ask this question but I don't
>>know where to ask it. If somebody knows, please redirect me.
>>
>>I am writing a backup script using bash and I want to log the output in
>>"/var/log/backup.log"
>>The saved files have to be stored on an external hard drive on "/dev/sda1"
>>
>>the script works and contains :
>>
>>    mount /dev/sda1
>>    ....
>>    cp /usr/Users/FolderToBackup /mnt/usb0/
>>    ....
>>    umount /dev/sda1
>>
>>On the terminal command line, I type :
>>
>>    ./backup >> /var/log/backup.log
>>
>>nothing is returned on the terminal and all the output is redirected to
>>"/var/log/backup.log".
>>It works always fine.
>>
>>Now, if the external hard drive is not present on "/dev/sda1" and I type :
>>    ./backup >> /var/log/backup.log
>>
>>On the terminal, I have :
>>    /dev/sda1 : Input/Output error
>>    mount : you must specify the filesystem type
>>    umount : /dev/sda1 not mounted
>>
>>My questions are :
>>
>>Why are these lines not logged in "/var/log/backup.log" ?
>>Is there a way to redirect it ?
>>
>>Or perhaps that I made a mistake in my script architecture (This is my
>>first script) :
>>I want to test an external  hard drive availability  on "/dev/sda1" by
>>doing a grep in "/var/log/backup.log". Does anybody knows a better way
>>to do it ? (better than logging the output of "mount" in
>>"/var/log/backup.log" and then testing it with a grep)
>>
>>Thank you for any answer,
>>
>>Jean LEE
>>
>>
>>
>>_______________________________________________
>>Whitebox-users mailing list
>>Whitebox-users at beau.org
>>http://beau.org/mailman/listinfo/whitebox-users
>>
>>    
>>
>
>
>
>  
>




More information about the Whitebox-users mailing list