Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Can someone please help me write a script that will perform the following commands together:
Code:
tar zcvf aria2.tar.gz /etc/aria2.conf /etc/init.d/aria2
tar zcvf minidlna.tar.gz /etc/minidlna.conf /etc/init.d/minidlna
tar zcvf nzbdrone.tar.gz /root/.config/NzbDrone /etc/init.d/nzbdrone
tar zcvf nzbget.tar.gz /etc/nzbget.conf /etc/init.d/nzbget
tar zcvf openvpn.tar.gz /etc/openvpn/server.conf /etc/init.d/openvpn
tar zcvf vsftpd.tar.gz /etc/vsftpd.conf /etc/init.d/vsftpd
If I run these commands one at a time, they execute without any errors.
How do I write the script?
Can someone please give an example.
First, there are THOUSANDS of very easily-found scripting examples you could find with a brief Google search, in less time than it took you to post this. There is even one in my posting signature.
Also, you have already written the script...put those commands in a file...make it executable. There is your script.
Thank you joe_2000 for the example. I already tried this before I asked for help. I always receive this error message at the end:
Code:
tar: \r: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar: Removing leading `/' from member names
/etc/nzbget.conf
/etc/init.d/nzbget
tar: \r: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar: Removing leading `/' from member names
/etc/openvpn/server.conf
/etc/init.d/openvpn
tar: \r: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar: Removing leading `/' from member names
/etc/vsftpd.conf
tar: /etc/init.d/vsftpd\r: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
: not found.sh: 8: backup.apps.sh:
: not found.sh: 9: backup.apps.sh:
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
If you had posted this as you were asked to do earlier your problem could have been solved.
Looks like you dont have linux line endings, the \r is a carriage return and is not used in linux it is used in windows, I assume you have wriiten your script on a windows machine, using somthing like notepad, you need to use linux endings ( \n ) so use a linux text editor, leafpad for example.
Last edited by Keith Hedger; 07-06-2015 at 06:35 PM.
Reason: spelling
Do you see all those \r? That's a carriage return. Usually happens when you move text from a system like Windows to Unix-like.
You need to remove them first.
Code:
sed -e 's/\r$//' file_with_carriage > file_without_carriage
Thank you joe_2000 for the example. I already tried this before I asked for help.
If I may recommend: Try and make it a habit to actually include such information in your initial question. When you run into problems, error messages are the most valuable information for people to be able (and willing) to help.
Not only do they prove you actually tried something for yourself but they also provide pointers as to what went wrong.
Furthermore, before even posting a question: When you get error messages, copy and paste them into the search engine of your choice. Chances are that someone has had this problem before you, and the solution is already available on the web.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.