Solved

'simple' script / tar archive problem

Posted on 2006-10-24
5
314 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

805 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