Help with a simple script and JAVA

ooooer! I don’t often venture in here!
Here Be Penguins!

Mainly because I know very little about scripting and even less about Programing!
Anyway in my quest to make my computer life MS free, I came upon this little script which I hope to solve a small problem I have.

##########################################################################
## 							                                            ##
## Project: B2B/Entraction poker launcher for LINUX users.		        ##
## Tested:  Working OK on Ubuntu 8.04+. Should be fine with	            ##
##			all other Linux Operating Systems.		                    ##
## Reasons: Allows Linux users to run the poker client from their	    ##
##          hard drive in similar fashion to the Windows install	    ##
##          version. Using the browser (Applet) version doesn't		    ##
##          allow users to save Hand History or Player Notes due	    ##
##          to Applet security policy that protects the end user.	    ##
##	        The client also runs significantly faster without the	    ##
##	        overhead of the browser plugin/Applet.			            ##
## Version:	0.3							                                ##
## Created: 9th October, 2008. New clients added April 2009             ##
## Author:  BIRCHY.							                            ##
## Website: http://bespokebots.com                                      ##
## NOTE:    Requires a JRE version 1.5 sub folder                       ##
## 									                                    ##
##########################################################################

#!/bin/bash

# set client variable (uncomment as req'd...others can be found by looking at the Applet page HTML source)
CLIENTNAME=noiqpoker
#CLIENTNAME=betdaqpokercom
#CLIENTNAME=24hPoker
#CLIENTNAME=devilfish
#CLIENTNAME=pokerium
#CLIENTNAME=i4poker
#CLIENTNAME=bambapoker
#CLIENTNAME=club4aces
#CLIENTNAME=martins
#CLIENTNAME=nordicbookmakers
#CLIENTNAME=pokerhills
#CLIENTNAME=pokersaints
#CLIENTNAME=skandiabet
#CLIENTNAME=stingbet
#CLIENTNAME=supremapoker


# check/create folder
DIR="./SKINS/$CLIENTNAME"
mkdir -p $DIR

# download files (will only download if server files are newer)
echo "ext-resources.remote.url=http://download.b2bpoker.com/client/$CLIENTNAME/ext-resources.jar" > "$DIR/ext-resources.properties"
wget -N -P $DIR http://download.b2bpoker.com/client/$CLIENTNAME/ext-resources.jar
wget -N -P $DIR http://download.b2bpoker.com/client/pokerclient.jar
wget -N -P $DIR http://download.b2bpoker.com/client/resources.jar
wget -N -P $DIR http://download.b2bpoker.com/client/crypt.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-jce-api.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-jce-provider.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-message.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-openpgp.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-pki.jar
wget -N -P $DIR http://download.b2bpoker.com/client/updater.jar

# launch client
# NOTE: you will need to copy a jre folder into the same directory as this script (must be version 1.5.x.x)
# Ubuntu example of how to get the jre folder:
#   1) in a terminal, run "sudo apt-get install sun-java5-jre".
#   2) now copy the jre folder from "/usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre" to the same directory as this script.
# This script uses a single jre for all skins (unlike the Windows version which copies the jre to every install!)
 
cd $DIR
script_path=`dirname "$0"`
"$script_path"/jre/bin/java -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp


I have a slight worry that running it might do something I don’t want it to, the fact that it was from someone calling himself “bespokeBots” gives me some concern, Bots are very much discouraged in internet poker!

I have read it and it looks kosher enough, but could one of you kindly gurus have a quick scan to reassure me please?

Secondly, as well as my lack of knowledge about scripting and programming, I know even less about JAVA. When the comment says “launch client” How do I do this, surely the client is an .exe?
The clients I use are NOIQ and Devilfish.
In my /usr/lib/**/ directory I have the following mess:

http://i127.photobucket.com/albums/p145/wakou/linuxpoker1.png

Should I have all of these?

Just previewing the post I read the script again, do I just run the script without even first having downloaded the app, and the script does it for me??

O do not understandd half of what you are talking about, but:

The script seeems to be a bash script, which it only says at line 21. That line should be the very first for it being effective. That said, when somebody makes such a severe mistake, I would not have any trust in the rest of this script.

When you say “surely the client is an .exe”, I think you are living in a different world. Or I am in a different world.

Well after much migrainery and head thumping, I finally got this to work!

:):slight_smile:

I had to change the last couple of lines;

cd $DIR
script_path=`dirname "$0"`
"$script_path"/jre/bin/java -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp

Does not work, giving “file not found”

In the end, I told it explicitly where to look, thus:

cd $DIR
~/poker_launcher/jre/bin/java -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp

Now this works for me, but will not, of course work for anyone else, or if I move the directories. I am new to scripting with bash, and variables make my head spin. Could someone please have a look at the original and tell me how it trips up? I can’t see what the bit that says:

script_path=`dirname "$0"`

actually does or what it refers to! Surely we have not defined $0 anywhere?
Or is $0 some kind of pre-set value?

I find it amazing that a big company would pay to have people coding in JAVA, (It’s multi-platform, duh!) and then only market it as windows software! The program itself runs perfectly in Linux… In addition to the pre-set list in the script, all these poker sites use the same software, and presumably shut out a lot of potential customers by not telling them that the software runs perfectly happily in Linux (and no doubt on a MAC)
List of poker sites using this software:


- Pinnacle Sports
- 24hPoker
- NoIQ Poker
- Bet1128 Poker
- BetDAQ Poker
- WINUnited Poker
- 10Bet Poker
- Nasty Duck
- Martins Poker
- IberoBet Poker
- I4Poker
- RedBet Poker
- Betlads
- Kerching Casino & Poker Room
- Club4Aces
- FishNChips Poker
- Kojak Poker
- M8 Poker
- Poker Panthers
- Bet4E Poker
- Black Sea Poker
- Play Cherry
- 4Kings
- Poker Hills
- CircleBet
- Pokerium
- Devilfish Poker
- Black Card Poker
- Dry Poker
- NorPoker
- 110Bet Poker
- 3B Win Poker
- 66 Poker
- Ace Off Spades
- Arctic Bet Poker
- Asso Kappa
- Asteria Poker
- Babylonbet Poker
- Be 52 Poker
- Betting Hills
- Black Town Bet
- BlueBay Poker
- Cap Bet Poker
- DanBook Poker
- Dane Poker
- Doc Holliday Poker
- Double Cardrooms
- ePoker King
- Equal Chance Poker
- Evil Table
- Facce da Poker
- Farsi Poker
- Fjordbet Poker
- FrontBet Poker
- Global Student Poker
- GoldWin Poker
- Golf’n Bet Poker
- Goodguys Poker
- High5 Action
- Hungry Poker
- Irish Eyes Poker
- JetBet Poker
- Kickoff Poker
- Klonk Poker
- Mad-Croc Poker
- Mets Poker
- MrBet
- NetKing Poker
- No Bull Glocal Poker
- No1Poker
- Nordic Bookmakers Poker
- PassionBet
- Perpetuum Poker
- PF Games
- Plum Gaming
- Point Poker
- Poker Ants
- Poker Biker
- Poker FTW
- Poker Paratiisi
- Poker Plaza
- Poker Saints
- Pokerdassi
- Pokeriasema
- Poker Mambo
- PokerSens
- PotRaiser
- Pro-Factory
- Raybet
- Real Poker 24
- SensePoker
- Sirius Poker
- Skandia Bet
- Spiral Poker
- Staff Poker
- Toro Poker
- U vs Poker
- U2Poker
- Wansino
- Wasa Poker
- XProBet
- Pokerihuone
- Sunmaker Poker
- ScoBet Poker
- Pokerimaa
- Dreamland Poker
- EuroStar Poker
- Casino Nazionale Poker
- Pokerisuora
- Sting Bet Poker
- Suprema Poker
- Vadet Bettington

The variable $0 expands to the name of the shell or shell script. This is set at shell initialization. If bash is invoked with a file of commands, $0 is set to the name of that file.

dirname $0 returns the path, i.e. it strips the non-directory suffix from the file name.

Henk, the bit at the top is patently obviously a preamble and not part of the actual script, even a total noob like me can see that putting the shebang #!bin/bash after it has no bearing whatever on it’s effectiveness!

When you say “surely the client is an .exe”, I think you are living in a different world. Or I am in a different world.

I told you I am unfamiliar with this! I also said that after more study of the script I thought that maybe the script itself gets and runs the JAVA, which indeed it does. It is the fact that the poker site in question only offers an .exe file to download that confused me.

Thank-you Voodoo, “one step forward!”…

I do not understand then, why it does not find the ~/poker_launcher/jre
when the script is at ~/poker_launcher/devifish.sh?

For this we need

ls -l ~/poker_launcher

And yes, ${0} ist he first argument of the call that started the script like ${1} is the second argument, etc. So when you call the script *jan *like

jan piet klaas

${0} will return jan, ${1} will return *piet and ${2} will return klaas. And ${} will return piet klaas, the posotional parameters from 1 onwards.

For the tool *dir *see

man dir

. It returns the directory path part of a full file specification, like *basename *will return the filname part.

The ... construct is very out of date (say more then 25 years). You should use the $( … ) construct. It returns the output of the command within the $( … ).

Thus

script_path=`dirname "$0"`

better:

script_path=$(dirname "${0}")

returns the path to the filename of the script call and puts that into the variable script_path.

wakou: from which directory and how do you call the script?

Thanks to you both, I feel embarrassed at calling on your superbrains for such a trivial issue!

Here it is:

stephen@home:~/poker_launcher> ls -l
total 16892
-rwx------ 1 stephen users     3316 2009-12-20 19:32 devifish.sh
drwxr-xr-x 8 stephen users     4096 2009-12-20 17:42 jre
-rwxr-xr-x 1 stephen users 17281664 2009-12-20 17:32 jre-1_5_0_21-linux-i586.bin
drwxr-xr-x 4 stephen users     4096 2009-12-20 17:52 SKINS

To call it I have made a desktop icon with the following:
(ignore the ref. to ./cxoffice, I just used the icon picture from there) This works BTW, but with the last line pointing directly to the jre dir

[Desktop Entry]
Comment[en_GB]=
Comment=
Encoding=UTF-8
Exec=/home/stephen/poker_launcher/devifish.sh
GenericName[en_GB]=
GenericName=
Icon=/home/stephen/.cxoffice/Devilfish/windata/Desktop.C^5E3A^5Fusers^5Fcrossover^5FDesktop/Devilfish+Poker.xpm
MimeType=
Name[en_GB]=Devilfish Poker
Name=Devilfish Poker
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-Created-By=cxoffice-4cf4c276-fb41-4bf0-9821-c5e4df4248cd
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

So just so I am clear:


script_path=`dirname "$0"`
script_path=$(dirname "${0}")

Both do exactly the same, except that the second one is preferred?

Except when you think that the fact that you call the whole by cklicking on an icon produces the error, the whole icon clicking is completely uninteresting. Things should first work from the CLI, where you can see what error messages are produced.

No please show us the real problem you have. Is this the error you get about some file not found? When yes then excute the script, let it produce its output and copy/paste everything here. Until now yopu only told there is an error message, but you did not show (copy/paste) it here.


About the script_path- lines.
Of course they produce the same. That is what I said. The second is better imho because

  1. it used $( ) instead of
  2. it used { } around parameters which is good shell programming practice
    But, as the whole script seems to be written by a noob, those two improvements are only minor. I did not tell you this for making the script better, but for
  3. answering your questions about it
  4. trying to teach you a bit of bash script writing
  5. lure you in reading man pages

And when you think that I am also trying to teach you how to document a problem when presenting it to other people for help, you may be right :wink:

Voodoo explicitly asked me:

wakou: from which directory and how do you call the script?

So I put it in the reply!

No please show us the real problem you have. Is this the error you get about some file not found? When yes then excute the script, let it produce its output and copy/paste everything here. Until now yopu only told there is an error message, but you did not show (copy/paste) it here.

Henk, To do that I would have to delete all I have done so far (got it working), and set it all up again so that does not work, all this to show you exactly what I have already told you!
You don’t believe what I have said above? You think I made it up or imagined it?
As it happens I sent an email…

poker_launcher.sh: line 67: ./jre/bin/java: No such file or directory

So I tried the java line manually: I copied the jre directory in to the skins directory

stephen@home:~/poker launcher/SKINS> jre/bin/java -cp
pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp
bash: jre/bin/java: No such file or directory
stephen@home:~/poker launcher/SKINS> jre/bin/java -cp
pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp
Exception in thread “main” java.lang.NoClassDefFoundError: ui/PokerClientApp

wakou: bash scripts are very easy to debug. Make it show what happens and you will see what’s wrong. Just throw in some additional commands.

What it was:

cd $DIR
script_path=dirname "$0"
“$script_path”/jre/bin/java -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp

Make it to look like this:

echo “DIR=$DIR”
cd $DIR
echo “We are here:”
pwd
echo “contents of ${DIR}:”
ls -l
script_path=$(dirname “${0}”)
echo “script_path=$script_path”
echo “Executing command:”
echo “$script_path”/jre/bin/java -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp

Another note: why should the script do all the wget stuff again and again when you want to start the application? That part of the script should only download something unless it is not already there.

TY Voodoo! good idea about echo-ing everything, unf I would not have known exactly how 'till you told me…

From the orig script:

# download files (will only download if server files are newer)

*All *poker clients do an update check on launch, many of them upgrade, bug-fix, tweak and fiddle the software on a monthly, weekly and sometimes daily basis!

I will go a bit off topic to explain why I ask what I ask.

In more then 30 years of helping people searching for bugs there is one recurring fact. People are human and they often jump over the very place where the bug is because somewhere deep in themselves they are sure ‘it is not there’. This is not on purpose or because off stubborness, it is just so.

When they come to you with their program listing for help, often the very fact that they have to explain the listing brings them to a “Oh, now I see”. And they walk away happily, thanking you for you help and you still does not understand what it is all about.

Now in a Forums like this it is very difficult to see the listings and I am always very suspicious about people telling things. Some are experienced users, but some are not, I often do know nothing about their grade of experience. Both often think they understand what their problem is and where it is about. But the very fact that they nevertheless did not find the bug often proves that they are looking in the wrong place. It is therefore that I ask for listings made through copy/paste and put between CODE tags (I have seen white space errors ignored because of not using fixed width fonts).

I hope this explains my method of bug searching a bit. When it is not possible for you to comply to this, we have to use other ways. May be I guessed your experience by way of the lousy script (not even starting correct). :wink:

The script seeems to be a bash script, which it only says at line 21. That line should be the very first for it being effective. That said, when somebody makes such a severe mistake, I would not have any trust in the rest of this script.

When you say “surely the client is an .exe”, I think you are living in a different world. Or I am in a different world.

home based business,home business
web tools,web hosting service

Have you had a sex change at the weekend Henk?

rotfl! I do not know who this anna_002 is. It is her first post, but not a very inventive one rotfl!

Here is how I updated the script(which was really poorly written) and there is another 100 ways to improve it:

#!/bin/bash
##########################################################################

Project: B2B/Entraction poker launcher for LINUX users.

Tested: Working OK on Ubuntu 8.04+. Should be fine with

all other Linux Operating Systems.

Reasons: Allows Linux users to run the poker client from their

hard drive in similar fashion to the Windows install

version. Using the browser (Applet) version doesn’t

allow users to save Hand History or Player Notes due

to Applet security policy that protects the end user.

The client also runs significantly faster without the

overhead of the browser plugin/Applet.

Version: 0.3

Created: 9th October, 2008. New clients added April 2009

Author: BIRCHY.

Website: How make a living from the internet

NOTE: Requires a JRE version 1.5 sub folder

##########################################################################

CUR_DIR=$(pwd) #to have the location of the script

set client variable (uncomment as req’d…others can be found by looking at the Applet page HTML source)

CLIENTNAME=noiqpoker
#CLIENTNAME=betdaqpokercom
#CLIENTNAME=24hPoker
#CLIENTNAME=devilfish
#CLIENTNAME=pokerium
#CLIENTNAME=i4poker
#CLIENTNAME=bambapoker
#CLIENTNAME=club4aces
#CLIENTNAME=martins
#CLIENTNAME=nordicbookmakers
#CLIENTNAME=pokerhills
#CLIENTNAME=pokersaints
#CLIENTNAME=skandiabet
#CLIENTNAME=stingbet
#CLIENTNAME=supremapoker

check/create folder

DIR="./SKINS/$CLIENTNAME"
mkdir -p $DIR

download files (will only download if server files are newer)

echo “ext-resources.remote.url=http://download.b2bpoker.com/client/$CLIENTNAME/ext-resources.jar” > “$DIR/ext-resources.properties”
wget -N -P $DIR http://download.b2bpoker.com/client/$CLIENTNAME/ext-resources.jar
wget -N -P $DIR http://download.b2bpoker.com/client/pokerclient.jar
wget -N -P $DIR http://download.b2bpoker.com/client/resources.jar
wget -N -P $DIR http://download.b2bpoker.com/client/crypt.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-jce-api.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-jce-provider.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-message.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-openpgp.jar
wget -N -P $DIR http://download.b2bpoker.com/client/cryptix-pki.jar
wget -N -P $DIR http://download.b2bpoker.com/client/updater.jar

launch client

NOTE: you will need to copy a jre folder into the same directory as this script (must be version 1.5.x.x)

Ubuntu example of how to get the jre folder:

1) in a terminal, run “sudo apt-get install sun-java5-jre”.

2) now copy the jre folder from “/usr/lib/jvm/java-1.5.0-sun-1.5.0.16/jre” to the same directory as this script.

This script uses a single jre for all skins (unlike the Windows version which copies the jre to every install!)

#this verifies if any version of java was installed previously:

1. if true you should find the version which needs to be > 1.5.x.x as I couldn’t think of a solution

2. if false it will attempt to install it(didn’t verify if sudo apt-get works)

and if the installation is unsuccesfull to exit

ls -l $(which java) || sudo apt-get install sun-java5-jre || echo “An error has occurred when install java” && exit

cd $DIR
script_path=$(dirname “${0}”)

#this eliminates the need to copy the jre folder
$(which java) -cp pokerclient.jar:resources.jar:ext-resources.jar ui.PokerClientApp

Thankyou for your efforts, dmera.

  1. I don’t see the need to get Java every time
  2. sudo apt-get!? shurley shome mishtake?? This IS an openSuse forum! zypper?.. anyhow;
  3. sudo apt-get install sun-java5-jre no longer works, java version is at v6 (1.6 or even v7 (1.7) now. Also you have to register with SUN to download SUN software so automating it is more trouble than it is worth.
  4. I THINK the software only works with 1.5.x.x and not with>1.5.x.x so copying the jre into the directory is the simplest way.

In any case the script looks much neater and is thus much more understandable. And as a consequence wakou sees the weak points like apt-get.

And my hobby horse: you started writing ${0} on my instigation. The same is true for $DIR. I would write ${DIR}. Now this is NOT to make you change everything. I only want to bring over the message that using consistent ways of doing things increases the quality of the product immensely. And there are cases where you have to use the { }, so for me it is then always { }.
Think of: ${0%/}* to get about the same thing as dirname ${0}.
Or ${VAR}IABLE which is definitely different from $VARIABLE.