Trying to do a bit of automation... but nooooo.

Epic stupid.. I forgot the `pwd` and trailing /, disregard this. Leaving the text up for a good laugh.

Maybe I'm just wicked tired, or I'm totally stupid. But I can't see where the problem is. I keep getting an unexpected operator at line 44, and if I remove said operator, I get another message. So here goes... halp?

Error before removing line 44:

kruesephiikz@kaos:~$ sh winebuild
Archive found. [ /home/kruesephiikz/wine-1.1.44.tar.bz2 ] correct? [ Y/N ]
y
Archive correct, move along.
[: 44: wine-1.1.44: unexpected operator
Something went wrong. Check error.

Error after removing line 44:

kruesephiikz@kaos:~$ sh winebuild
Archive found. [ /home/kruesephiikz/wine-1.1.44.tar.bz2 ] correct? [ Y/N ]
y
Archive correct, move along.
winebuild: 104: Syntax error: end of file unexpected (expecting "fi")

Line 44 content:

 fi 

Sript:

#!/bin/sh
if [ -f `pwd`/wine*.tar.bz2 ]
then 
    echo Archive found. [ `pwd`/wine-*.bz2 ] correct? [ Y/N ]
        read yn1
            case $yn1
                in
                    "y")    echo "Archive correct, move along."
                        sleep 2
                        break;;
                        
                    "n") echo "Archive incorrect, kill script."
                        exit;;
            esac
else
    echo Archive not found... abort
    exit
fi

if [ -d wine-* ]
then
    echo Previous directory found, remove? [ Y/N ]
    read yn2
        case $yn2
            in
                "y") echo "Deleting old directory."
                    rm -r `pwd`/wine-*/
                    echo "Extracting Wine archive."
                    sleep 2
                    tar -xvf `pwd`/wine-*.tar.bz2
                    break;;
                "n") echo "Cannot delete, exit."
                    exit;;
        esac
else 
        if [ $? -ne 0 ]
        then
            echo Something went wrong. Check error.
            exit
        fi
    echo Directory not found, continuing to extract.
    sleep 2
    tar -xvf `pwd`/wine-*.tar.bz2
fi

echo Compile starting, change directory.
sleep 2
cd wine-*

echo Create symlinks? [ Ubuntu-64 Users Only ] [ Y/N ]
read yn3
    case $yn3
        in 
            "y") echo "Creating Symlinks, please wait."
                sleep 2
                    mkdir -p `pwd`/lib32
                    ln -s /usr/lib32/libX11.so.6 `pwd`/lib32/libX11.so
                    ln -s /usr/lib32/libXext.so.6 `pwd`/lib32/libXext.so
                    ln -s /usr/lib32/libfreetype.so.6 `pwd`/lib32/libfreetype.so
                    ln -s /usr/lib32/libfontconfig.so.1 `pwd`/lib32/libfontconfig.so
                    ln -s /usr/lib32/libGL.so.1 `pwd`/lib32/libGL.so
                    ln -s /usr/lib32/libGLU.so.1 `pwd`/lib32/libGLU.so
                    ln -s /usr/lib32/libXrender.so.1 `pwd`/lib32/libXrender.so
                    ln -s /usr/lib32/libXinerama.so.1 `pwd`/lib32/libXinerama.so
                    ln -s /usr/lib32/libXxf86vm.so.1 `pwd`/lib32/libXxf86vm.so
                    ln -s /usr/lib32/libXi.so.6 `pwd`/lib32/libXi.so
                    ln -s /usr/lib32/libXrandr.so.2 `pwd`/lib32/libXrandr.so
                    ln -s /usr/lib32/liblcms.so.1 `pwd`/lib32/liblcms.so
                    ln -s /usr/lib32/libpng12.so.0 `pwd`/lib32/libpng.so
                    ln -s /usr/lib32/libcrypto.so.0.9.8 `pwd`/lib32/libcrypto.so
                    ln -s /usr/lib32/libssl.so.0.9.8 `pwd`/lib32/libssl.so
                    ln -s /usr/lib32/libxml2.so.2 `pwd`/lib32/libxml2.so
                    ln -s /usr/lib32/libjpeg.so.62 `pwd`/lib32/libjpeg.so
                    ln -s /usr/lib32/libXcomposite.so.1 `pwd`/lib32/libXcomposite.so
                    ln -s /usr/lib32/libcups.so.2 `pwd`/lib32/libcups.so
                    ln -s /usr/lib32/libXcursor.so.1 `pwd`/lib32/libXcursor.so
                    ln -s /lib32/libdbus-1.so.3 `pwd`/lib32/libdbus-1.so
                    ln -s /usr/lib32/libhal.so.1 `pwd`/lib32/libhal.so
                    ln -s /usr/lib32/libsane.so.1 `pwd`/lib32/libsane.so
                    ln -s /usr/lib32/libgphoto2.so.2 `pwd`/lib32/libgphoto2.so
                    ln -s /usr/lib32/libgphoto2_port.so.0 `pwd`/lib32/libgphoto2_port.so
                    ln -s /usr/lib32/libldap-2.4.so.2 `pwd`/lib32/libldap.so
                    ln -s /usr/lib32/libldap_r-2.4.so.2 `pwd`/lib32/libldap_r.so
                    ln -s /usr/lib32/liblber-2.4.so.2 `pwd`/lib32/liblber.so
                    ln -s /usr/lib32/libxslt.so.1 `pwd`/lib32/libxslt.so
                    ln -s /usr/lib32/libcapi20.so.3 `pwd`/lib32/libcapi20.so
                    ln -s /usr/lib32/libjack.so.0 `pwd`/lib32/libjack.so
                    ln -s /usr/lib32/libodbc.so.1 `pwd`/lib32/libodbc.so
                    ln -s /usr/lib32/libgnutls.so.26 `pwd`/lib32/libgnutls.so
                    echo "Symlinks created."
                    sleep 2
                break;;
            "n")  echo "Hopefully a non 64-bit user. If you are on 64-bit Ubuntu, CTRL-C Now and restart."
                sleep 1
                break;;
    esac

echo Compiling now! 
sleep 2
CC="gcc-4.4 -m32" LDFLAGS="-L/lib32 -L/usr/lib32 -L`pwd`/lib32 -Wl,-rpath,/lib32 -Wl,-rpath,/usr/lib32" ./configure -v
make -j5 -s depend
make -j5 -s
wineserver -k
sudo make -j5 install

Thanks a ton for taking a look. :slight_smile:

Believe it or not, the script works like a charm if the directory isn't found. If it is, however, this is the error I receive.

The same code worked fine for me, try something like this:

 
tar -xvf `pwd`/wine\-*.tar.bz2

Hi,

You can aslo use the debug option to identify the root cause of the problem.
put

set -x 

below the line

#!/bin/sh

and give it a try to find out where the problem lies.

Thanks

Thanks for the suggestions guys, I got it working last night. The problem was here:

if [ -d wine-* ]
then
    echo Previous directory found, remove? [ Y/N ]
    read yn2
        case $yn2

It should have been:

if [ -d `pwd`/wine-*/ ]
then
    echo Previous directory found, remove? [ Y/N ]
    read yn2
        case $yn2

you might also opt to make the whole thing easier on the machine's overhead by replacing each

`pwd`

with a quicker reference to

$PWD

, better yet

${PWD}

when embedded in a string. This won't spawn a process to identify an already known value within your shell, thus reducing overhead.

Otherwise, if you prefer that the machine work for it's power, you could simply bump your inline functions up a notch and make them more legible by using $(...) instead of `...`. 99% of the time they're interchangeable...and much easier to spot in a crowd...

HTH

Thanks for the tips, curleb!

I have another question. I'm trying to pipe grep properly into wget, and that wouldn't be so hard.. if there wasn't a problem.

I'm trying to have the script look for the archive, got that down. But if the archive isn't found, I want it to connect to this website:

http://ibiblio.org/pub/linux/system/emulators/wine/

And download the file wine.lsm
I can do that. Then I want to:

cat wine.lsm | grep wine-*.bz2 > winever

I can do that. But here's the problem. When I try and

 wget http://ibiblio.org/pub/linux/system/emulators/wine/`< winever`

It doesn't work, because there's a large space at the beginning of the file, which wget interprets as a newline and thus fails by trying to connect to wine-1.whatever.tar.bz2 and not downloading the file. How can I fix that?

I'm not blessed with wget (or even curl) although I'd venture a guess that this is mostly a shell parsing issue at its root. I'd figure you'd want to remove the spaces, then you'd run into the fact that there's more than one such line...

Here's the contents of that file from your alternate site:

Begin4
Title: Wine
Version: 1.1.44
Entered-date: 2010-05-07
Description: Wine is an Open Source implementation of the Windows API on top of X and Unix.
Keywords: wine, windows, win32, emulation
Author: wine-devel@winehq.org (the Wine development team)
Maintained-by: julliard@winehq.org (Alexandre Julliard)
Primary-site: ftp://ibiblio.org /pub/linux/system/emulators/wine
	wine-1.1.44.tar.bz2
	wine-1.1.44.diff.bz2
Alternate-site: http://prdownloads.sourceforge.net wine
Platforms: Linux, FreeBSD, NetBSD, Solaris, MacOS/X
Copying-policy: LGPL
End

Two .bz2 files, each preceded with a longer whitespace segment. I'm not so familiar with wget, as I'd said, so I don't know if it would handle them as a glob/array, or as a single result (which might be where you're inferring a newline). Assuming it doesn't like globs, you'd have to devise a loop to handle multiple bogeys...and then you'd also need to eliminate that space at the beginning.

This would likely work to eliminate the extraneous spaces:

$ cat Edit4
Begin4
Title: Wine
Version: 1.1.44
Entered-date: 2010-05-07
Description: Wine is an Open Source implementation of the Windows API on top of X and Unix.
Keywords: wine, windows, win32, emulation
Author: wine-devel@winehq.org (the Wine development team)
Maintained-by: julliard@winehq.org (Alexandre Julliard)
Primary-site: ftp://ibiblio.org /pub/linux/system/emulators/wine
        wine-1.1.44.tar.bz2
        wine-1.1.44.diff.bz2
Alternate-site: http://prdownloads.sourceforge.net wine
Platforms: Linux, FreeBSD, NetBSD, Solaris, MacOS/X
Copying-policy: LGPL
End
$ grep bz2 Edit4
        wine-1.1.44.tar.bz2
        wine-1.1.44.diff.bz2
$ grep bz2 Edit4 |sed "s/[\t ]//g"
wine-1.1.44.tar.bz2
wine-1.1.44.diff.bz2

This kills the cat and leaves at least a few more cycles out of the overhead. But this now leaves you with the exercise of figuring out wget's preference on this result.

HTH

I figured it out moments before you posted this, solution follows:

					"n") echo "Archive incorrect, get new version info."
						wget http://ibiblio.org/pub/linux/system/emulators/wine/wine.lsm
						cat wine.lsm | grep 1.*.tar.bz2 > winever
						break;;
			esac
echo Download new version? `cat winever` [ Y/N ]
read dl
	case dl
		in
			"y") echo "Downloading new archive"
				sleep 1
				wget http://ibiblio.org/pub/linux/system/emulators/wine/`cat winever | sed -e 's/^[ \t]*//'`
				break;;
			"n") echo "Exiting script"
				exit;;
	esac