BackupPC-users

Re: [BackupPC-users] rm command does not work in ArchivePreUserCmd

2008-10-23 11:18:19
Subject: Re: [BackupPC-users] rm command does not work in ArchivePreUserCmd
From: Adam Goryachev <mailinglists AT websitemanagers.com DOT au>
To: backuppc-users AT lists.sourceforge DOT net
Date: Fri, 24 Oct 2008 02:15:55 +1100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tino Schwarze wrote:
> On Fri, Oct 24, 2008 at 03:51:55AM +1300, Peter McKenna wrote:
>> Tried that, but no difference.
>> Executing ArchivePreUserCmd: /usr/local/bin/archivepreusercmd.sh
>>
>> rm: cannot remove `/archives/*': No such file or directory
>> Archive failed: ArchivePreUserCmd returned error status 256
> 
> Ah, I see. Fact is that there is no file '/archives/*'. Try the
> following as /usr/local/bin/archivepreusercmd.sh:
> 
> #!/bin/bash
> #
> 
> for file in /archives/* ; do
>   [ -f "$file" ] && rm -f "$file"
> done
> 
> This ensures that there is actually something to delete.

Or you could do it in two lines:
#!/bin/bash
rm -f /archives/*

Or you could do it in three lines:
#!/bin/bash
touch /archives/test
rm -f /archives/*

Or you could do it like this (approx)
#!/bin/bash
find /archives/ -type f -exec rm -f {}
(I never seem to get my find -exec commands to work properly, but it
should work if you get the parameters right.

BTW, keep in mind /archives/* will never match /archives/.somefile etc

Finally, like all things in unix, there are dozens of ways to solve a
problem :)

PPS, for most of the above "scripts" you probably don't need the
#!/bin/bash on the first line, because it doesn't matter which shell
interprets the commands, they should all "do the right thing"....

BTW, "man rm" will provide some hints on how to use the rm command,
including using -f "ignore nonexistent files, never prompt"

Regards,
Adam
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJAJUrGyoxogrTyiURAouuAJ9ZqEdLWxZpkgKJprU2ntouYXGiMQCgjMiD
cgTD1XJXzcSaO8udA3hjslw=
=wKQq
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/