[afnog] mv not mv-ing solved (stupidity)

Frank Habicht geier-lists-afnog at tih.co.tz
Wed Sep 19 12:04:08 UTC 2007


Oh my $deity !

So Frank wrote a script and towards the end he removed a file
and then he wonders for days why the file isn't there.
Are there drugs for that problem?

Thank for helping me look from different angles!

the
#FLOWARCHIVEDIR
was meant as a switch, archiving processed files or deleting.
one part of my brain implemented that (deleting in this case),
and another part was still looking for the file...
I should tell them to talk to each other.

And thanks Patrick, I should really check for both,
variable set and directory existing.

Thanks,
Frank

On 9/19/2007 2:30 PM, Patrick J Okui wrote:
> Hi Frank,
> 
> As a hint to why this isn't working, replacing your second echo $? with
> an exit or an ls -l will show you that you created the file...
> 
> On 19 Sep, 2007, at 1:58 PM, Frank Habicht wrote:
> 
>> #FLOWARCHIVEDIR=${FLOWDIR}/archive
> 
> .... which means this variable is unset
> 
>> #rm or mv
>> if [ "${FLOWARCHIVEDIR}" ]; then
>>  /bin/mv -f ${MYFLOWFILE} ${FLOWARCHIVEDIR}/ 2>/dev/null
>> else
>>  /bin/rm -f ${MYFLOWFILE} 2>/dev/null
>> fi
> 
> 
> hmm... not sure what test you want to run here. do you want to test if
> the variable has been set? if [ -n ${...} ] or do you want to test if
> the directory exists? if [ -d ${ ... } ] or both? if [ -n ${..} -a -d ${
> ...} ] ...
> 
> Also, removing the 2>/dev/null is always good when debugging since it'll
> give you errors, you should try it.
> 
> I'm guessing that on the first machine
> 
> 1. you have a FLOWARCHIVEDIR set
> 2. the archive directory exists.
> 
> 
> -- 
> patrick
> 
> 
> 




More information about the afnog mailing list