VT creat script have error, how to fix it?

General discussion about Celestia that doesn't fit into other forums.
Topic author
divine_vessel
Posts: 19
Joined: 10.01.2004
With us: 20 years 5 months
Location: China
Contact:

VT creat script have error, how to fix it?

Post #1by divine_vessel » 20.06.2004, 15:10

I found the VT creation script can't be executed. It have errors.I use "#" to disable each line that contain an error an find these:

Code: Select all

[root@localhost c]# sh ./vt
'/vt: line 62: syntax error near unexpected token `
'/vt: line 62: `    ((offy = j * tilesize))
[root@localhost c]# sh ./vt
'/vt: line 62: syntax error near unexpected token `
'/vt: line 62: `    ((offy = j * tilesize))
[root@localhost c]# sh ./vt
./vt: line 66: syntax error near unexpected token `elif'
'/vt: line 66: `        elif [ "$4" = "w" -o "$4" = "W" ]; then
[root@localhost c]# sh ./vt
'/vt: line 77: syntax error near unexpected token `
'/vt: line 77: `        ((offx = i * tilesize))
[root@localhost c]# sh ./vt
'/vt: line 80: syntax error near unexpected token `
'/vt: line 80: `        ((i++))
[root@localhost c]# sh ./vt
./vt: line 84: syntax error near unexpected token `fi'
./vt: line 84: `fi '
[root@localhost c]# sh ./vt
./vt: line 85: syntax error: unexpected end of file

I know little about shell script,so I don't know how to fix it.I hope some one here could help me .Thanks alot.
I put the origin file here as well

Code: Select all

#! /usr/bin/zsh
if [ $# -lt 3 -o "$1" = "--help" ]; then
  echo
  echo 'Usage: virtualtex [--help | <texture name> <tile size> <tile format>] [e|E|w|W]'
  echo
  echo
  echo The shell script \'virtualtex\' is a tool for Celestia \> 1.3.0
  echo that supports \'virtual textures\'.
  echo
  echo The script generates the required tiles tx_i_j of \
       desired \(square\) size, 
  echo \<tile size\>, in a specified format, \<tile format\> = \
       png, tga, jpg,...,
  echo from an input texture, \<texture name\>, in any popular graphics format.
  echo
  echo The optional 4th argument e\|E\|w\|W is for the case of tiling 
  echo square /e/astern \| /w/estern halfes of the full texture separately!
  echo 
  echo Besides Linux/Unix, the script also runs in a current Cygwin \
       installation
  echo under Windows, \( http://www.cygwin.com \). If the z-shell \(\'zsh\'\) \
       is unavailable,
  echo it also may be executed with the \'bash\' shell, by replacing \
       \#\! /usr/bin/zsh by
  echo \#\! /bin/bash in the first line.
  echo
  echo The script assumes that a recent version of the ImageMagick package
  echo \( http://www.ImageMagick.org \) is installed \
       \(either under Unix/Linux or Windows\).
  echo The utilities \'convert\' and \'identify\' of that package are used.
  echo
  echo You may increase the pixel cache size \$maxmem from the 80 MB default
  echo value to e.g. 80\% of your RAM size within the script with an editor.
  echo This will speed up the performance of \'virtualtex\' considerably.
  echo
  echo On a PIII/512MB RAM the tiling of a 16k x 8k texture into
  echo 32 \(2k x 2k\) tiles now only takes 15 minutes with a Linux OS!
  echo
  echo Author: Dr. Fridger Schrempp, fridger.schrempp@desy.de
  echo Version: 1.03, 08/16/03
  echo 
else
maxmem=80
texturesize=`identify $1|cut -d " " -f 3`
texturewidth=`echo $texturesize|cut -d x -f 1`
textureheight=`echo $texturesize|cut -d x -f 2`
tilesize=$2
tileformat="$3"
echo
echo "Texture size = " $texturewidth "x" $textureheight "tilesize = " $tilesize
echo "Number of tiles =" $(( ((texturewidth/tilesize)) * ((textureheight/tilesize)) ))
echo "Image format of tiles:" $tileformat
echo
echo "Tile: "
echo

convert -cache $maxmem -crop ${tilesize}x${tilesize} $1 out%d.$tileformat

j=0

while (( j * tilesize + tilesize <=  textureheight )); do
    ((offy = j * tilesize))
    if [ $# -eq 4 ]; then
   if [ "$4" = "e" -o "$4" = "E" ]; then
       ioff=$(( texturewidth/tilesize ))
   elif [ "$4" = "w" -o "$4" = "W" ]; then
       ioff=0
        else
            echo
            echo "*** Incorrect 4th parameter! ***"
            echo
            return
        fi
    fi
    i=0
    while (( i * tilesize + tilesize <= texturewidth )); do
        ((offx = i * tilesize))
        echo "tx_"$((i + ioff))"_"${j}":  x-offset:" $((offx + ioff * tilesize)) "y-offset:" $offy
    mv out$((i+ ((texturewidth/tilesize)) * j)).$tileformat tx_$((i + ioff))_${j}.$tileformat
        ((i++))
    done
    ((j++))
done
fi

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 21 years 10 months
Location: NY, USA

Post #2by selden » 20.06.2004, 15:38

divine_vessel,

I think the problem is that this shell script requires the "zsh" shell interpreter, but it looks like you typed the command
sh ./vt

This told Linux to use the "sh" shell interpreter.

sh is a simple programming language.
zsh is more complex.
sh doesn't understand zsh commands.

If you type only
./vt
then Linux will use the interpreter that is specified the first line of the script: /usr/bin/zsh

zsh is included with most Linux distributions, but you can get the newest Zsh at http://www.zsh.org/

Does this help?
Selden

Topic author
divine_vessel
Posts: 19
Joined: 10.01.2004
With us: 20 years 5 months
Location: China
Contact:

Post #3by divine_vessel » 21.06.2004, 04:25

I have download zsh-2.40 and installed it on my redhat9 linux.I run the script with "zsh ./vt" but It still encounters errors at the same line as before.

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 3 months
Location: Hamburg, Germany

Post #4by t00fri » 21.06.2004, 10:26

divine_vessel wrote:I have download zsh-2.40 and installed it on my redhat9 linux.I run the script with "zsh ./vt" but It still encounters errors at the same line as before.


Try making my script executable by typing

Code: Select all

chmod a+x ./vt

and then copy it (as root) to /usr/local/bin with

Code: Select all

cp ./vt /usr/local/bin

next start it by just calling it by its name, of course with all necessary arguments furnished!

Another issue that might be relevant arises if you have downloaded my script from a site that has accidentally introduced DOS CR-LF's as line endings!

Download the latest, original version of my script from my TextureFoundry site. It should be virtualtex (version 1.03):

http://www.shatters.net/~t00fri/virtualtex

Bye Fridger

Topic author
divine_vessel
Posts: 19
Joined: 10.01.2004
With us: 20 years 5 months
Location: China
Contact:

Post #5by divine_vessel » 24.06.2004, 13:16

Thank you
I 'll try it.


Return to “Celestia Users”