If you want to install and run the bridge program on your own computer, see this post.
If you want to know how to run the bridge program as a web server, see this post.
Using the web page to interact with the server program is certainly the most fun, but there is one more way to use the bridge program: running it from a script.
I don’t address the “why” of scripting in this post, only the “how”. More on “why” in a future post.
These instructions are for Unix-based systems. Your mileage may vary on other types of operating system.
Please note that you do not have to have the web server version of the bridge program running in order to run the program from a script. Scripts run the program directly, without reference to the web server entry point. You do, however, need the web server version running if you want to use the web page as shown in these instructions. If you have a local copy of the program but you don’t want to try to run the web server yourself, you can also use the web page on my public server for the browser interactions shown here, but then use your local copy of the program for the scripting interactions.
First, in a terminal, navigate to the scripts folder of your bridge program installation:
cd ~/Documents/Documents/web-projects/bridgeOnTheWeb/public/scripts
On the bridge program web page, select Random deal type, North dealer, N/S vulnerable, and 1 for number of deals. There’s nothing special about those values—I just want you to see how your selections affect the resulting script.
Now click the “Deal” button.
As always, you will get a deal in the deal area. But now notice the “Generated Script” area at the bottom of the page. You will see what may look like a bunch of jibber-jabber, but if you are a *nix programmer you will recognize this as code in the bash scripting language. It may be valid in other scripting languages as well, but the author runs it in a bash terminal. Check it out:
What can you do with that script? There’s a neat trick you can do but it’s not the recommended way of using this feature. You can actually copy that script text to your clipboard, then paste it into a terminal window. There, it will run and it will create a deal file based on your spec. Let’s try it. Here’s my innocent terminal window showing the contents of my public/scripts folder:
Back over on the web page, I selected all of the contents of the Generated Script text box and copied it to my clipboard. Then I pasted it onto the command line in my terminal window, at which point it immediately runs! I then typed “ls” to list the folder contents post-run:
The green text is output from the bridge program, showing the values that were passed to it on the command line in the script. All of those originated from the web page based on our selections before clicking the “Deal” button.
With the script you automatically get extra goodies. See the *.lin and *.pbn files that showed up after we ran the script? Those contain your deal in those formats. Also notice the folder called BridgeOutAheadFolder1. Listing the contents of that folder shows you this:
You get text files with all of the hands, each hand separately, the analysis, and the *.lin and *.pbn files (again). I call this “The Instructors’ Delite Grab Bag O’ Goodies”. Actually no I don’t call it that, but I can imagine some ways to use these things in an instructional setting.
That covers running a script immediately. But even better is the ability to save off the script in case you want to run it again. Now, you could have pasted that script text into a script file, but you don’t have to do that because I provide the “Script” button on the web page. Look for it on the line underneath the line with the “Deal” and “Browse” buttons. When you click on it you will get something like this, that shows evidence of saving off your script text in a named file:
That file with the *.sh extension is a bash shell script. It is saved to my Downloads folder. Here’s what it looks like:
Hey, it’s the stuff from the Generated Script text box!
You can copy that *.sh file to your bridge scripts folder and run it there. There’s just one little gotcha, which is that the file might not be in *nix format and it might not be executable. Just use chmod and dos2unix to solve those problems. You will only need to do those things once for any one script file.
Then run the script, and you will see output similar to when you ran the script on the bare-naked command line (you can tell I did some trial runs so I have more than one script file):
Enjoy!