[nycphp-talk] [OT] Calling All Shell Scripters!
Phillip Powell
phillip.powell at adnet-sys.com
Fri Oct 8 11:48:12 EDT 2004
D Sandmann wrote:
>Try this:
># SYNTAX: delete_tar $folderPath $origFolderName $today
> delete_tar()
> {
> echo "Are you sure you want to delete TAR file ""$1/${2}_${3}.tar.gz""?
> (Y/N Enter = N) "; read isOKDelete
> if [[ "$isOKDelete" = "Y" -o "$isOKDelete" = "y" ]]; then
> rm $1/${2}_${3}.tar.gz
> fi
> }
>
>If that does not work, then let me know and I will come up with something
>better.
>
>
I'm sorry but it didn't work, off-the-bat syntax error:
/home/me/scripts/icatalog_unpackager.sh: line 21: syntax error in
conditional expression
/home/me/scripts/icatalog_unpackager.sh: line 21: syntax error near
unexpected token `-o'
/home/me/scripts/icatalog_unpackager.sh: line 21: ` if [[ "$isOKDelete"
= "Y" -o "$isOKDelete" = "y" ]]; then'
I've never heard of "[[ ]]" before, simply because I was taught to use
Shell Script with as much of the external UNIX capabilities as possible
and as little built-in shell, if that makes sense.
Phil
>BTW, the double [[ ... ]] uses the shell built in test command. What you where
>trying to use would call the external UNIX test command.
>
>Also instead of using echo, you can use print which is built into the shell
>language.
>
>Disclaimer: The above recommendations should work under ksh and I believe most
>shells are enhancements to the ksh. (Although I could be wrong since I only
>work in ksh anyways)
>
>David
>
>--- Phillip Powell <phillip.powell at adnet-sys.com> wrote:
>
>
>
>>I know you know Shell Script, you're all LAMP demigods out there, so I'm
>>not surprised you dream in Shell Script as well. In any case, I need
>>some help with a very simple function I wrote for a command-line
>>PHP-based application program migrator I wrote:
>>
>># SYNTAX: delete_tar $folderPath $origFolderName $today
>>delete_tar()
>>{
>> echo "Are you sure you want to delete TAR file ""$1/${2}_${3}.tar.gz""?
>>(Y/N Enter = N) "; read isOKDelete
>> if [ $isOKDelete = "Y" -o $isOKDelete = "y" ]; then
>> rm $1/${2}_${3}.tar.gz
>> fi
>>}
>>
>>------------------------------
>>--------------------------------------------------
>>
>>I continually get the "too many arguments" error on the "if" line if I
>>do not enter either "Y" or "y".
>>
>>[Quote]
>>/home/me/scripts/icatalog_unpackager.sh: [: too many arguments
>>[me at www me]$
>>[/Quote]
>>
>>As dumb as this is going to sound, how must I do this correctly? I have
>>already gone to Linux Shell Script tutorials and apparently am not
>>grasping this.
>>
>>Thanx
>>Phil
>>
>>--
>>
>>
>>
>---------------------------------------------------------------------------------
>
>
>>Phil Powell
>>Multimedia Programmer
>>BPX Technologies, Inc.
>>#: (703) 709-7218 x107
>>Fax: (703) 709-7219
>>
>>
>>
>>_______________________________________________
>>New York PHP Talk
>>Supporting AMP Technology (Apache/MySQL/PHP)
>>http://lists.nyphp.org/mailman/listinfo/talk
>>http://www.newyorkphp.org
>>
>>
>>
>
>
>=====
>David
>
>Be happy with what you have and are, be generous with both, and you won't have to hunt for happiness. - William E. Gladstone (1809 - 1898)
>
>Get Firefox! (http://www.spreadfirefox.com/?q=affiliates&id=0&t=1)
>
>
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail - Helps protect you from nasty viruses.
>http://promotions.yahoo.com/new_mail
>_______________________________________________
>New York PHP Talk
>Supporting AMP Technology (Apache/MySQL/PHP)
>http://lists.nyphp.org/mailman/listinfo/talk
>http://www.newyorkphp.org
>
>
>
--
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107
Fax: (703) 709-7219
More information about the talk
mailing list