[nycphp-talk] [OT] Calling All Shell Scripters!
D Sandmann
crackerdog22 at yahoo.com
Fri Oct 8 11:33:18 EDT 2004
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.
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
More information about the talk
mailing list