ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
(you need to specify a file at the end of the path)
What I'm trying to do is to back up the users' folders I have on my server, and when they run it to generate the backup in the /tmp path, I'm learning to make scripts.
I don't know what the cause is since I run it from the terminal and here it doesn't mark this message.
I'm unable to replicate the OPs problem. Their tar command creates a tar file of everything in the user's home directory with no "errors" or problems...
m0rt When you get the message, is the tar file not created?
I'm unable to replicate the OPs problem. Their tar command creates a tar file of everything in the user's home directory with no "errors" or problems...
m0rt When you get the message, is the tar file not created?
Yes, it does generate the file for me but my doubt is because it sends me the error, because I ran this script in SUSE and it doesn't send me errors, but in Ubuntu I get the message.
Yes, it does generate the file for me but my doubt is because it sends me the error, because I ran this script in SUSE and it doesn't send me errors, but in Ubuntu I get the message.
I can see that would cause a question.
Couple more suggestions:
Compare the version and the man pages on the two machines. Look for a difference in what they say about the [FILE]...
(Although my man page seemed to say the last option had to be a file or list of files, but worked with ${USER} just fine.)
List the contents of the tar file where you get the "error" (I think it's only a warning if it's creating the file) to confirm that it contains all it should...maybe create a test user so it's not some huge collection of files to check.
What on Earth are those marked backtics supposed to be doing? What is happening is that the shell runs the tar command and then tries to interpret the verbose output as another command. The first line of that output will be the user's home directory, and the shell is complaining that a directory cannot be a command.
the -P is for me to respect the absolute paths otherwise it sends me another error message of the character "/"
Yes, that’s because typically having absolute path names in tar archives is a bad idea and may be dangerous. What you want is:
Code:
tar -C /home -cvf "/tmp/resp-$USER-$Fecha.tar" "$USER"
or slightly less magical:
Code:
cd /home; tar -cvf "/tmp/resp-$USER-$Fecha.tar" "$USER"
Unless you really want full path in the archive in which case:
Code:
tar -C / -cvf "/tmp/resp-$USER-$Fecha.tar" "/home/$USER"
Quote:
Originally Posted by scasey
I can see that would cause a question.
Couple more suggestions:
Compare the version and the man pages on the two machines.
No need for such tedious tasks. tar --version would very likely show that both systems use the same tar.
Quote:
Originally Posted by jsbjsb001
From tar's man page:
Code:
tar [OPTION...] [FILE]...
Once again, read it.
Perhaps OP has read it and noticed:
Code:
For example, the c option requires creating the archive, the v option
requests the verbose operation, and the f option takes an argument that
sets the name of the archive to operate upon. The following command,
written in the traditional style, instructs tar to store all files from
the directory /etc into the archive file etc.tar verbosely listing the
files being archived:
tar cfv a.tar /etc
Emphasis mine. So yeah…
(But what confused me the most is why people continued discussing this after I’ve pointed out the problem).
Yes, that’s because typically having absolute path names in tar archives is a bad idea and may be dangerous. What you want is:
Code:
tar -C /home -cvf "/tmp/resp-$USER-$Fecha.tar" "$USER"
or slightly less magical:
Code:
cd /home; tar -cvf "/tmp/resp-$USER-$Fecha.tar" "$USER"
Unless you really want full path in the archive in which case:
Code:
tar -C / -cvf "/tmp/resp-$USER-$Fecha.tar" "/home/$USER"
No need for such tedious tasks. tar --version would very likely show that both systems use the same tar.
Perhaps OP has read it and noticed:
Code:
For example, the c option requires creating the archive, the v option
requests the verbose operation, and the f option takes an argument that
sets the name of the archive to operate upon. The following command,
written in the traditional style, instructs tar to store all files from
the directory /etc into the archive file etc.tar verbosely listing the
files being archived:
tar cfv a.tar /etc
Emphasis mine. So yeah…
(But what confused me the most is why people continued discussing this after I’ve pointed out the problem).
This happened to me to run my script. It came out as follows:
Code:
tar -C / -cvf "/tmp/resp-$USER-$Fecha.tar" "/home/$USER"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.