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


  Search this Thread
Old 07-17-2011, 10:51 PM   #1
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 -@

But when I add it to a script (.sh) I get the error below:

(contents of
filename=`date +%Y-%m%d-%H:%M`
find /mnt/user/ -maxdepth 3 -name user.xml -type f | zip -rp $ -@

)ip error: Invalid command arguments (no such option

Any thoughts?
Old 07-17-2011, 10:58 PM   #2
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, 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: 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, 09:19 AM   #4
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,846

Rep: Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097Reputation: 3097
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, 10:49 AM   #5
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 :-)


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

All times are GMT -5. The time now is 01:05 AM.

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