Solved

'simple' script / tar archive problem

Posted on 2006-10-24
5
295 Views
Last Modified: 2010-05-19
Hi,

I've the following problem:

When I want to restore multiple files with tar i use the following syntax:

tar -xvf /mnt/usbdrive/backup/vantriest-Fri.tar file1.jpg file2.doc file4.jpg

because of some files have some spaces in the filenames I set the files between comments

tar -xvf /mnt/usbdrive/backup/vantriest-Fri.tar 'file1.jpg' 'file2.doc' 'file4.jpg' 'long filename.jpg'

this works fine .. but not in a script!?!
When I do the exact same thing at the prompt it works fine...
What do i wrong?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
the script
-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-
#!/bin/sh
cd /mnt/restore

tar -xvf /mnt/usbdrive/backup/deburg-Fri.tar 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/offertedeburg.doc' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/deburg.ppt' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/zoekcriteria www.deburgmakelaars.nl.doc'

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Output
=-=-=-=-=-=-=-=-=-=-=-=
[root@backup backup]# /tmp/commands.sh
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/deburg.ppt
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/deburg.ppt: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/zoekcriteria www.deburgMakelaars.nl.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/zoekcriteria www.deBurgMakelaars.nl.doc: Cannot open: No such file or directory

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Thanks in advance,

V.R. Jansen
0
Comment
Question by:wanted4u
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Malohi earned 63 total points
ID: 17796420
First of all you have a difference in you capitalization between the commandline and the script.  This is probably your problem.  deburgmakelaars website is not capitalized on the command line but it is in the script.


If that doesn't work it might not like the quotes.  You can try just escaping the spaces.  You can even do this inside the quotes.  It should look like this: 'deburgmakelaars\ website'

Then the interpreter will know that it is a space and not another file.

0
 
LVL 10

Expert Comment

by:ssvl
ID: 17872601
Hi Malohi,

use escape charaters of blank spaces

eg mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc it is wrong path

actulay it is like  /mnt/deburg/deBurgMakelaars/deBurgMakelaars\ website/offertedeburg.doc  change this then only your scrit work


0
 
LVL 10

Assisted Solution

by:ssvl
ssvl earned 62 total points
ID: 18026003
or simply use a "

like "mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand" it taks the path with spaces
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now