Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-24-2010, 05:45 AM   #1
Registered: Aug 2010
Posts: 49

Rep: Reputation: 0
Error in my script

Hi All,

I ve task to take a back up a folder from remote server,i wrote a script for create a file with extent ion of .tar.gz but i got an error is given below in red color font.

cur_date=`date +%d-%m-%Y`
`tar -czvf $filename $servicepath`

when i ran this script i got an error like
[root@localhost ~]# sh
tar: Removing leading `/' from member names line 7: /etc/httpd/: is a directory
[root@localhost ~]#

Finally i need sloution for that error and a script to copy the tar.gz file in to remote server

Hariharan V.
Old 08-24-2010, 05:53 AM   #2
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Why place it around `?
tar -czvf "$filename" "$servicepath"
Old 08-24-2010, 07:48 PM   #3
Registered: Aug 2007
Location: Fort Collins, Colorado
Distribution: Gentoo
Posts: 64

Rep: Reputation: 17
Yeah, putting those backhashes around 'tar -czvf $filename $servicepath' is telling bash to run the output of that command.

For instance, running `echo ls` in a shell will process 'echo ls' and then execute it, in effect running 'ls'.

Maybe you already know how backhashes work. In any case, that's your problem.

P.S. In my experience it's better to use $() instead of `` since it's easier to read and you can nest. For instance, you might want to replace "cur_date=`date +%d-%m-%Y`" with "cur_date=$(date +%d-%m-%Y)". Not that it will change your script. It's just easier to read IMO.

P.P.S A good tutorial on Bash scripting can be found here.

P.P.P.S What kind of services is your server running? SSH? Samba? FTP?

Last edited by kinetic; 08-24-2010 at 07:57 PM.
1 members found this post helpful.
Old 08-25-2010, 01:01 AM   #4
Registered: Aug 2010
Posts: 49

Original Poster
Rep: Reputation: 0
Services is running on SSH
Old 08-25-2010, 01:55 AM   #5
Registered: Aug 2007
Location: Fort Collins, Colorado
Distribution: Gentoo
Posts: 64

Rep: Reputation: 17
scp ${filename} username@server:/path/to/copy/file
This is will require you to enter in your password on the remote server. You can look into setting up password-less SSH if you want to automate this. Just Google it.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 09:37 AM
bash script read error and awk ouptut error whited Programming 4 10-16-2007 08:05 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 10:10 PM
error when tying to run python script(bash error?) shanenin Programming 5 01-10-2006 11:01 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration