I will do some tutorials on the different programs and hopefully that will be a good start.
If I may chime in an opinion.
You have been trying for sometime to make a Bash wrapper for some Perl code. You mentioned Awk as well. I have the feeling you have been trying to absorb as much you could of any and all of these scripting means.
Why do you not concentrate a bit on just Perl and make that concept you have been trying a robust one? Perl would be a more homogenous and robust solution; and creating a menu is not that difficult on it. The end result of learning Perl is that it would benefit far more in your scientist projects that the shell or even Awk could do.
Don,
thank you for the hint.
Is it possible to make the functions "return", without major changes?
I admit I misused the functions as goto replacement
Your code assumes that each patient will only have one panel (so you have your user enter a patient ID and a panel number together). My code assumes that a single patient will frequently go through multiple panels (so I have my user enter a patient ID and then enter panel numbers in a loop for that patient; and when all panels have been processed for that patient, loop through other patients).
To get rid of the recursion in your code, remove the additional function and change every call to additional into a return statement. You will then either need to insert a loop into your menu function or at the end of your script, change:
to:
And then, finally, remove the call to menu in menu and change calls to menu in match to return statements.
These 2 Users Gave Thanks to Don Cragun For This Post:
That is a great suggestion Aia. I have been trying to make a bash to make it easier for users to use without needing much scripting, ideally none but as little as needed. Anyway, below is a start (I hope):
I am not sure if that is correct or how to call a command based on the menu selection. For example, if 1 is inputed, then something like this needs to result.
Thank you all for the great suggestions and ideas, I have a lot to learn .
If you are serious about it, you are going to have to learn and figure out what this line does first and how to converted from a command line invocation to a Perl code script. Calling Perl inside Perl would be a bit silly.
Since it is very ugly and hard to read, I separated them in sections to facilitate understanding for you.
Also, you'll need to figure out how to deal with all those shell variables, like ${id}, ${panel}, etc. Perl would not inherit those from the shell automatically.
Once, you do that, you might be ready for a menu.
There are many ways of doing it, depending on the design. Here's just a guide:
There are no substitute for practicing and practicing some more.
After practice for some time, you could take a look at CPAN and search for menus. There are some modules to build some menus, like Term::Menus
Last edited by Aia; 11-13-2014 at 01:43 AM..
Reason: Missing last braquet
If you write a lot of perl, look into the utility perltidy, it will save you many times over. Always look in your repositories for perl codes, there are a ton of libraries available. You might find some things at The Comprehensive Perl Archive Network - www.cpan.org that are useful. I never install anything in my system unless I use the package manager (apt-get, yum zypper, etc), but rather I put codes in ~/bin, and ~/executable.
We used O'Reilly books in the perl classes I taught. You are out of the beginner state when you have written 100 non-trivial programs ( drl's rule ) I'd recommend Learning, Intermediate, and Mastering for a full course. You didn't say what your field is, but if it's the life sciences, then the Bioinformatics might be useful.
A few books from publisher Manning are also useful, Data Munging, and OO perl.
Thank you . My field is life sciences, specifically Molecular Diagnostics and genetics. Bioinformatics is a necessary and important skill to have and develop.
Hi All,
There is a code like below in my script
###############################################
###Create Directories and Sub-Directories
###############################################
dpdir=DP_FROM_${from}_TO_${to}
mkdir $dpdir
cd $dpdir
mkdir AWQM WFCONTROLLER PROVCO PRISM
... (1 Reply)
I am trying to do the following task :
export ENV=aaa
export ENV_PATH=$(cd /apps | ls | grep $ENV)
However, it's not working. What's the way to change to directory and search some file in that directory in single command
Please help. (2 Replies)
Hi,
I Installed mysql on my CentOS 6.2 Server. But when I tried to change the location of /var/lib/mysql to another directory. I can't start the mysql. Below is what I've done
yum install mysql mysql-server mysql-devel
mkdir /path/to/new/
cp -R /var/lib/mysql /path/to/new
chown -R... (1 Reply)
I have a simple shell script that prompts the user to enter a directory to navigate to.
What i want it to do and i don't know how to do this is if the directory is invalid automatically navigate to the home directory.
echo "enter a directory to navigate to:"
read directory
cd $directory... (6 Replies)
I have a directory of files and each file has a random 5 digit string at the beginning that needs to be removed. Plus, there are some files that will be identically named after the 5 digit string is removed and I want those eliminated or moved.
any ideas? (17 Replies)
I have a directory that is existing under my root dir of the FTP server. The DIR name is 'Software Patch'. I want to move in to that DIR to download some patches. But, when I issued a command 'cd SOftware Patch', the system said that it cannot find the dir 'Software'. I tried all possible ways like... (2 Replies)
I would like to have a script that would change my current working directory. However, any time I execute a 'cd' command in a script, it holds only for the life of that script -- the working directory on exit is the same as when the script was initiated. Is it possible to have the script return... (3 Replies)
hi,
Iam in directory A. I run a script from there. inside the script i have a command cd B.
When i come out of the script directory is A only.
Even when i come out scrip i want the directory to be B
How to achieve (2 Replies)
Hi all,
I'm trying to wirte a small shell script in Linux. My script has the flow like,
cmd1
cmd2
cd testdata
cmd3
After exiting the program, the CWD remains the same as where I execute the program. I need it to be changed to the latest updated directory in the program. How can I do... (1 Reply)