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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to do a bit of automation... but nooooo.
# 1  
Old 05-17-2010
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:
Code:
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:
Code:
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:
Code:
 fi

Sript:

Code:
#!/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. Smilie

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.

Last edited by KruesephiikZ`; 05-17-2010 at 12:36 AM..
# 2  
Old 05-17-2010
The same code worked fine for me, try something like this:

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

# 3  
Old 05-17-2010
Hi,

You can aslo use the debug option to identify the root cause of the problem.
put
Code:
set -x

below the line

Code:
#!/bin/sh

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

Thanks
# 4  
Old 05-17-2010
Thanks for the suggestions guys, I got it working last night. The problem was here:

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

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

# 5  
Old 05-17-2010
you might also opt to make the whole thing easier on the machine's overhead by replacing each
Code:
`pwd`

with a quicker reference to
Code:
$PWD

, better yet
Code:
${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
# 6  
Old 05-17-2010
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:
Code:
http://ibiblio.org/pub/linux/system/emulators/wine/

And download the file wine.lsm
I can do that. Then I want to:
Code:
cat wine.lsm | grep wine-*.bz2 > winever

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

Code:
 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?
# 7  
Old 05-17-2010
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:
Code:
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:

Code:
$ 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
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies

2. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

3. Red Hat

boot the 32 bit kernel on a 64 bit PPC Linux machine?

Hi all, I'm looking to cover a corner case for an upcoming test cycle. Is there a way to boot a RedHat Advanced Server 4 (update 3) installed on a Power PC machine to use a 32 bit kernel? This would be similar to what is done here -> https://www.unix.com/aix/26204-aix-platform.html I've done... (0 Replies)
Discussion started by: philrau
0 Replies

4. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies
Login or Register to Ask a Question