public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* problem with sh script
@ 2002-09-10  2:40 Philippe Rousselot
  2002-09-10  5:51 ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Rousselot @ 2002-09-10  2:40 UTC (permalink / raw)
  To: cygwin

Hi,

I have the following script.
it works fine under Linux. but blocks under Cygwin

I get this error message:
/usr/local/bin/thumbnail: 25:Syntax error: word unexpected (expecting ")")

line 25 is array=('' '' '')


thanks in advance for your help


~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh

# ~~~~~~~~ original credit ~~~~~~~~~~~~~
#vim: set sw=4 ts=4 et:
# wirtten by katja socher <katja@linuxfocus.org>
# and guido socher <guido@linuxfocus.org>
# ~~~~~~ end original credit ~~~~~~~~~~~

# I found the file at 
http://linuxfocus.org/English/July2001/article211.shtml

# the file has been heavily modified by myself
# to be able to create w3 compliant html page

# this is my first bash script, don't hesitate to email me any error or 
improvement

# Philippe Rousselot Aug. 2002,  EMail: linux at rousselot dot org


ver="1.0"
one=1
number=1
extension=".html"
page_numb=1 ;
j=0
array=('' '' '')

help()
{
cat <<HELP
	thumbnail_multipage -- generate W3 compliant html pages with thumbnails 
to click on for a number of images.
	USAGE: htmlthumbnails [-h] [ -W width] [-H height] [-N name_of_html_page] 
[-n number_of_image_per_page] path/image1 image2 ...
	OPTIONS: -h this help.
	EXAMPLE: htmlthumbnails -W 120 -H 80 -N page -n 6 image1 image2
	EXAMPLE: htmlthumbnails -W 80 -H 120 -N page -n 6 ~/images/*.jpeg
	The html code is written to files called name_of_html_page_file_number.html.
	I recommend leaving the script always in the same folder and using the 
absolute path for the images (~/path/image).
	All thumbnails have a size of widthxheight.
	Make sure you use the right orientation.

	This script requires ImageMagick

	if you modify the script, make sure the html file still validates as HTML 
4.01 Transitional!

	version $ver
HELP
exit 0
}


error()
{
	echo "$1"
	exit "$2"
	
}

header()
{
	#creates header for html page
	cat > $filename << EOF
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	        "http://www.w3.org/TR/html4/loose.dtd">

	<html>
	        <head>

	                <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; 
charset=ISO-8859-1">
	                <meta name="Author" LANG="fr" CONTENT="">
	                <meta name="Description" CONTENT="Page created with 
thumbnail_multipage">
	                <meta name="Description" CONTENT="">
	                <meta name="Keywords" LANG="fr" CONTENT="">
	                <meta name="Identifier-URL" CONTENT="http://">
	                <meta name="Reply-to" CONTENT="">
	                <meta name="revisit-after" CONTENT="31">
	                <meta name="Publisher" CONTENT="Quanta Plus">
	                <meta name="Copyright" CONTENT="">
	                <meta name="date" CONTENT="2002-07-06">
	                <meta name="Generator" CONTENT="Quanta plus, gFTP">

                         <title>   "$title"    </title>

	                <style type="text/css">
	                </style>

	        </head>
	        <body>

                 <table border =" 0" align="center" width ="500">
                         <tr align="center">




EOF
}


footer()
{
	cat >> $filename << EOF

                         <td></td><td>
                                 <!-- link for ./$title2 -->
                                 <a href="./$title2">$title2</a>
                         </td><td></td>
                 </tr>
         </table>

         <br>


			<p>
     				<a href="http://validator.w3.org/check/referer"><img border="0"
         			src="http://www.w3.org/Icons/valid-html401"
         			alt="Valid HTML 4.01!" height="31" width="88"></a>
   			</p>

	        </body>

	</html>
EOF
}

while [ -n "$1" ];
do
  case $1 in
	-h) help;shift 1;;
	--) break;;
	-W) width=$2; break;;
	-H) echo "wrong argument. It should be -W";exit 1;;
	-N) echo "wrong argument. It should be -W";exit 1;;
	-n) echo "wrong argument. It should be -W";exit 1;;
	-*) echo "error: no such option $1. -h for help";exit 1;;
	*)  break;;
	esac
done

while [ -n "$3" ];
do
  case $3 in
	-h) help;shift 1;;
	--) break;;
	-W) echo "wrong argument. It should be -H";exit 1;;
	-H) height=$4 ;break;;
	-N) echo "wrong argument. It should be -H";exit 1;;
	-n) echo "wrong argument. It should be -H";exit 1;;
	-*) echo "error: no such option $1. -h for help";exit 1;;
	*)  break;;
	esac
done

while [ -n "$5" ];
do
  case $5 in
	-h) help;shift 1;;
	--) break;;
	-W) echo "wrong argument. It should be -N";exit 1;;
	-H) echo "wrong argument. It should be -N";exit 1;;
	-N) name=$6 ; break;;
	-n) echo "wrong argument. It should be -N";exit 1;;
	-*) echo "error: no such option $1. -h for help";exit 1;;
	*)  break;;
	esac
done

while [ -n "$7" ];
do
  case $7 in
	-h) help;shift 1;;
	--) break;;
	-W) echo "wrong argument. It should be -n";exit 1;;
	-H) echo "wrong argument. It should be -n";exit 1;;
	-N) echo "wrong argument. It should be -n";exit 1;;
	-n) quota=$8 ; break;;
	-*) echo "error: no such option $1. -h for help";exit 1;;
	*)  break;;
	esac
done

dirname_image=`dirname "$9"`
th="thumbnails"
thumbnail_dir="$dirname_image/$th"
page_numb=`printf "%.2d" $page_numb` ;
filename="$dirname_image/$name$page_numb$extension";
title="$name$page_numb$extension";
mkdir "$thumbnail_dir"


if [ -z "$9" ];then
     error "No image specified, -h for help" 1
fi

# process each image
i=0;

header;

shift 8

for image in $* ;
do
	echo "$image"
     if [ ! -r "$image" ]; then
         echo "ERROR: can not read $image\n"
     else
         i=`expr $i + 1`
         bn=`basename "$image"`
         array[j]=$bn

         j=`expr $j + 1`
         thumbnail="$thumbnail_dir/t_$bn"

         convert -geometry "${width}x$height" "$image" "$thumbnail"

         cat >> $filename << EOF

         <td>
                 <!-- image nr $i -->
                 <a href="./$bn" name="$bn" type="image/jpeg">
                         <img src="./$th/t_$bn" width="$width" 
height="$height" alt="[$bn]" border=1>
                 </a>
         </td>
EOF
	modulo=`expr $i % 3`


         if [ "$modulo" = "0" ]; then
            cat >> $filename << EOF
            </tr>
            <tr align="center">
                 <td>
                         ${array[0]}
                 </td>
                 <td>
                         ${array[1]}
                 </td>
                 <td>
                         ${array[2]}
                 </td>
            </tr>
            <tr align="center">
                 <td>
                         <br>
                 </td>
                 <td>
                         <br>
                 </td>
                 <td>
                         <br>
                 </td>
            </tr>
            <tr align=center>
EOF
             j=0
             array=('' '' '')
         fi

	modulo=`expr $i % $quota`


	if [ "$modulo" = "0" ]; then

	    	page_numb=`expr $page_numb + 1`;
                 page_numb=`printf "%.2d" $page_numb` ;
		filename2="$dirname_image/$name$page_numb$extension";
		title2="$name$page_numb$extension";

		if [ "$number" -ne "$one" ]; then
			echo "<a href=\"javascript:history.back()\">Back</a>" >> $filename ;
		fi


		number=`expr $number + 1`
		i=0
		footer;
		filename=$filename2
		title=$title2

		header;
         fi

     fi
done
footer

#end script~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



-- 
Philippe Rousselot.

utilisateur GNU/Linux #275608

~~~~~~~~~~~~~
Any similarities to real life is completely fictitious.
Nor trees or animals were harmed in the composition of this email message.
However, a number of electrons were moderately inconvenienced.

~~~~~~~~~~~~~


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: problem with sh script
  2002-09-10  2:40 problem with sh script Philippe Rousselot
@ 2002-09-10  5:51 ` Corinna Vinschen
  2002-09-10  6:21   ` Philippe Rousselot
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2002-09-10  5:51 UTC (permalink / raw)
  To: cygwin

On Tue, Sep 10, 2002 at 11:22:39AM +0200, Philippe Rousselot wrote:
> #!/bin/sh
    ^^^^^^^
> [...]
> # this is my first bash script, don't hesitate to email me any error or 
                     ^^^^

Beep.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: problem with sh script
  2002-09-10  5:51 ` Corinna Vinschen
@ 2002-09-10  6:21   ` Philippe Rousselot
  2002-09-10  6:41     ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Rousselot @ 2002-09-10  6:21 UTC (permalink / raw)
  To: cygwin

Hi,

thanks. the lapsus calami revealed both my mistake and my ignorance.

so, there is no sh under cygwin?


Philippe

Corinna Vinschen wrote:
> On Tue, Sep 10, 2002 at 11:22:39AM +0200, Philippe Rousselot wrote:
> 
>>#!/bin/sh
> 
>     ^^^^^^^
> 
>>[...]
>># this is my first bash script, don't hesitate to email me any error or 
> 
>                      ^^^^
> 
> Beep.
> 
> Corinna
> 


-- 
Philippe Rousselot.

utilisateur GNU/Linux #275608

~~~~~~~~~~~~~
Any similarities to real life is completely fictitious.
Nor trees or animals were harmed in the composition of this email message.
However, a number of electrons were moderately inconvenienced.

~~~~~~~~~~~~~


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: problem with sh script
  2002-09-10  6:21   ` Philippe Rousselot
@ 2002-09-10  6:41     ` Corinna Vinschen
  0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2002-09-10  6:41 UTC (permalink / raw)
  To: cygwin

On Tue, Sep 10, 2002 at 02:55:04PM +0200, Philippe Rousselot wrote:
> Hi,
> 
> thanks. the lapsus calami revealed both my mistake and my ignorance.
> 
> so, there is no sh under cygwin?

sh = ash, not bash.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-09-10 13:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-10  2:40 problem with sh script Philippe Rousselot
2002-09-10  5:51 ` Corinna Vinschen
2002-09-10  6:21   ` Philippe Rousselot
2002-09-10  6:41     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).