LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 07-17-2011, 11:51 PM   #1
nixanwin
LQ Newbie
 
Registered: Mar 2010
Posts: 24

Rep: Reputation: 0
"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?
 
Old 07-17-2011, 11:58 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 07-18-2011, 08:29 AM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,194

Rep: Reputation: 105Reputation: 105
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.
 
Old 07-18-2011, 10:19 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
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.
 
Old 07-18-2011, 11:49 AM   #5
nixanwin
LQ Newbie
 
Registered: Mar 2010
Posts: 24

Original Poster
Rep: Reputation: 0
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 :-)
 
  


Reply


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
Running command in gnome-terminal from script results in "...error creating child..." PlancksCnst Linux - General 6 04-08-2009 01:09 PM
ns:"error when calling class OldSim"&tclsh:"invalid command+child process exits abn." shojaru Linux - Newbie 0 03-05-2009 05:23 AM
error: Error for wireless request "Set Mode" (8B06) : invalid argument "roaming" penguin chick Linux - Wireless Networking 5 08-22-2008 02:16 PM
Apache2 Error on Start "Invalid Command" Salen Linux - Newbie 1 12-29-2005 02:55 PM
Bash Script: Problem running variable command containing "" Paasan Programming 2 01-21-2004 02:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:45 AM.

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