[WBEL-users] Writing a script in bash

Graham David Purcocks M.A.(Oxon.) grahamp at wsieurope.com
Tue May 24 10:50:22 CDT 2005


Because >> means append standard output. Error messages are almost
certainly on standard error.

You probably need

./backup >> /var/log/backup.log 2>&1

which connects stderr to stdout.

Graham

On Tue, 2005-05-24 at 16:16, Jean Lee 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