Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
07-17-2011, 10:51 PM
|
#1
|
LQ Newbie
Registered: Mar 2010
Posts: 24
Rep:
|
"Invalid Command" error running .sh script
So what does it mean when I can run this command as root successfully from the command line (it will find all user.xml and zip):
find /mnt/user/ -maxdepth 3 -name user.xml -type f | zip -rp filename.zip -@
But when I add it to a script (.sh) I get the error below:
(contents of xml-backup.sh)
#!/bin/bash
filename=`date +%Y-%m%d-%H:%M`
find /mnt/user/ -maxdepth 3 -name user.xml -type f | zip -rp $filename.zip -@
Error:
)ip error: Invalid command arguments (no such option
Any thoughts?
|
|
|
07-17-2011, 10:58 PM
|
#2
|
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Rep: 
|
Two suggestions:
1. I'm not at all sure about the "-@" syntax.
Please consider writing a test script with a couple of sample files to see if it works.
2. Often, "invalid command" or "command not found" errors come from:
a) writing the shell script in Windows
b) running the script in Linux - without stripping DOS/Windows "CRLF" from the file first
Please look at your file in "vi" ("vi -b") and check for any funny "^M" characters in your file.
|
|
|
07-18-2011, 07:29 AM
|
#3
|
Senior Member
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep: 
|
When I look at the Linux man page for zip, I don't see the -p option. Your error message in fact indicates "no such option", but you seem to have clipped the error message or something when you entered it above, since it doesn't indicate which option it is complaining about.
|
|
|
07-18-2011, 09:19 AM
|
#4
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,042
|
And not that it should cause an issue, but you really should test the 'filename' setting on the command line to, so as to confirm it does not cause issues as the 2 lines are not the same.
|
|
|
07-18-2011, 10:49 AM
|
#5
|
LQ Newbie
Registered: Mar 2010
Posts: 24
Original Poster
Rep:
|
Thank you all for the replies. Per paulsm4, It was because I copied the script to notepad++ in Windows to edit - Doh! I re-created the script using nano and it seems to run fine. Noob mistake I guess but learning :-)
|
|
|
All times are GMT -5. The time now is 11:25 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|