bash script help
I have a friend who is taking an online course. She is doing very well, but is having trouble with bash scriptng. I have no knowledge of bash scripting syntax so I thought I would pass this along and see if anyone can point us in the right direction.
All this thing does is ask for input and then stops. Code:
#!/bin/bash Any help? Thanks... |
Change the first line from
Code:
#!/bin/bash Code:
#!/bin/bash -vxe |
There's a missing if after
Code:
if [“$RESPONSE” = "a"]; then As already pointed out, -!= should be != In the Create Links and File Permissions sections the variables are not initialised before use. As already pointed out, a case statement would be much better than all those ifs but maybe this exercise comes in the course before the case statement has been introduced and will be modified to use case later -- cleverly showing the student how much neater a case based solution is. The script should exit after the "please try again" errors or the user does ot have an opportunity to try again. Error messages are conventionally written to stderr, not echo's default stdout. Maybe this convention has not been introduced yet. A function to test directory existence and create a directory would be much neater. Maybe functions have not been introduced yet. EDIT: The Create Links section does not have a ln command (the first ls should be ln -s ?) Debugging would be easier if the commands were only displayed, not executed. This could be done by using a $debug variable as shown below (change to debug= when debugged). Code:
#!/bin/bash |
I told her I thought the -!= was wrong. :-D I had never seen that, but like I said, I'm not familiar with bash script syntax.
After I posted this I went downstairs and had dinner and she called me and said she had changed it to use a case statement and said it was working! She's pretty smart. She is going to send me the latest code. I'll post it up when I see it. I'll also point her back over to this thread and look at your suggestions, etc. Thanks for your input! |
Agree with all above comments, its mostly small details; nonetheless critical for proper functioning... :)
You/she may find these worth bookmarking if you/she haven't already http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
All times are GMT -5. The time now is 04:16 PM. |