User Tools

Site Tools


gtspring2009:howto:shell_scripts

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

**This page is probably woefully incomplete, but it worked for me without causing a catastrophic meltdown, yet. I hope group members more knowledgeable will edit this page where needed so this is safer to do. Plenty of information can be found on the interwebs.** Because many of us sleep some hours of the day and can't keep watchful guard over our computers at all times during the day even though our computers would like to be doing calculations even though we aren't here, I thought it would be useful if I posted a HowTo of writing shell scripts. I know these will be particularly helpful for me because I am still a first year grad student and I have lots of homework and can't man a terminal at all hours of the day. This might also be helpful when students start using the PACE cluster, as I'm pretty sure you send the cluster script files. === Simple Shell Script === * To create a simple shell script, first create a directory in your channelflow directory called, say test_script, so that you don't orphan any files. * Within the test_script directory, use your favorite text editor to create an extension-less file called my_script. * Enter the following into my_script #!/bin/bash # First script echo "That's easy" The first line is very important, don't leave it out. The second line is just a comment on what your script does, documentation good. The line without the '#' is what the computer actually executes. * (I'm not 100% sure about this step, but I blindly followed the seedy Linux site, and it worked.) Next, you need to change permissions on the file you just created so that it can be executed. Do this by entering the following command into your shell: [dustin@localhost test_script]$ chmod 755 my_script * Now you are ready to execute your shell script. You can do this using: [dustin@localhost test_script]$ ./my_script * Hopefully, your shell printed out "That's easy" right after you execute command, and you are done. === Unstable Manifold Example === It is important when you create a shell script to enter the commands into the script file exactly as you want them executed, with no typos or logic errors, or else the script file will bail on you and your preparation will be for not. We are going to create a script file to compute the 1-D unstable manifold of the Nagata Upper Branch Solution, similar to the tutorial example, just a different solution. You might want to save this for the end of the day, so all of your data will be available fresh in the morning the next day. * Name a directory where you want all of your data to be stored within channelflow, I used UB-eqb2. * Create a script file, I called mine UB_manif_script. * Enter the following into the script file: #!bin/bash/ #Some documentation here about what your script file does - documentation is extremely important. wget http://channelflow.org/database/a1.14_g2.5_Re400/UB.ff fieldplots -o plot UB arnoldi --flow UB.ff addfields 1 UB 0.01 ef1 UBp01ef1 addfields 1 UB -0.01 ef1 UBm01ef1 couette -T0 0 -T1 400 -o data-UBp01ef1 UBp01ef1 couette -T0 0 -T1 400 -o data-UBm01ef1 UBm01ef1 seriesprops -T0 0 -T1 400 data-UBp01ef1 -o props-UBp01ef1 seriesprops -T0 0 -T1 400 data-UBm01ef1 -o props-UBm01ef1 movieframes -T0 0 -T1 400 data-UBp01ef1 -o frames-UBp01ef1 movieframes -T0 0 -T1 400 data-UBm01ef1 -0 frames-UBm01ef1 * Change the permissions on the file using: [dustin@localhost UB-eqb2]$ chmod 755 UB_manif_script * Execute the script: [dustin@localhost UB-eqb2]$ ./UB_manif_script * Get back to doing something else and leave your computer for a few hours. This program took somewhere between 1 and 10 hours to run to completion, I don't know because I wasn't there when it finished.

gtspring2009/howto/shell_scripts.1235656850.txt.gz · Last modified: 2009/02/26 06:00 by dspieker