linux - tar returns 1 in script, but not interactively -


If I run the following shell script (ie the tar file then delete the source if it succeeds)

< Pre> #! / Bin / bash tar cvf /home/acampton/vortex_data/2014-02-14/tmp-2014-02-14-test2.tar-C / home / acampton / vortex_data / 2014-02-14 SIC_17_RADAR -2014-02- 14_all_no_dups.How if [$? -a 0]; Then "Delete files" - "Deleted" at the time of "Successful" ($?) And then "Delete echo files" - "Failed" ("$") "" Date < P> This returns 1 (the source file is being changed when stored)

  acampton @ ALIEN: ~ / work / spm $. / V1.sh SIC_17_RADAR-2014-02-14__all_no_dups.csv Do not remove files - Tar unsuccessful (1) Timed on February 18 10:38:16 EST 2014  

But if I run it interconnected, it works (every Bar!)

  Accepton @ ALIEN: ~ / work / spm $ tar cvf /home/acampton/vortex_data/2014-02-14/tmp-2014-02-14-test2.tar- C / Home / acampton / vortex_data / 2014-02 -14 SIC_17_RADAR-2014-02-14_all_no_dups.csv SIC_17_RADAR-2014-02-14_all_no_dups.csv acampton @ ALIEN: ~ / work / spm $ echo $? 0 Acampon @Elein: ~ / work / SPM $  

and I can guarantee that the source is not being modified on script (or interactive)

Ive also --exclude = everything_else_but_my_file Tried to use and get the same thing

Note that I'm not trying to tar (which usually "changes the file as we have read" Ni tried to prepare himself .tar file)

At the end of my rope - looking at the tar option, but it is necessary to know that this is happening, so I sleep in the night Any thoughts?

Any thoughts?

code> if position is backwards 0 success means non-zero failure Means you use -e instead of -e plus you've got an additional then .

  if [$? -E 0 0]; Then "delete files" - "delete" files at the "successful" ($?) Time and "delete files" at the time of the "unsuccessful" ("$") timed "unsuccessful" ($?)  < / Pre> 

, if a command succeeds, idler it should be entered correctly in the if statement.

  If tar cvf / home / Acampton / vortex_data / 2014-02 -14 / tmp-2014-02-14-test 2.-c / home / acipton / vortex_data / 2014-02-14 SIC_17_rade-2014-02-14_all_no_dups csv; then "$$$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Div>  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -