Ubuntu Breezy 5.10 (don't suggest an upgrade - it works!) I'm trying to set up a script which updates some software on the hard drive from a directory on a USB Flash drive. After I've plugged in the USB drive and seen it recognised by automount: ls -l /vol/USBDISKB OK - shows me the directory and files. -BUT_ #!/bin/bash if [ -d /vol/USBDISKB ]; then echo "Found USB drive" else echo "Not found: USB drive!" fi doesn't see the USB drive. :-(( P.S. I tried to edit so it looks like code. Really. 18/04/10 08:54 GMT Well! I don't know are am pretty stupid but I don't seem able to add a comment in response. All I seem able to do is edit my original post :( The obvious typos you can put down to my newbieness. If you are interested on following this question there has developed a much bigger thread here: |
There should be a semicolon before the else. This works in my rig
answered 17 Apr '10, 16:38 LiquidPaper Semicolons are only necessary when putting everything on a single line. The above script will work just fine, although, the ! may be interpreted as strangely depending on the verison of bash. Since there aren't any variables or expansion needed, I would recommend enclosing that particular string in single quotes.
(01 Mar '13, 13:55)
rfelsburg ♦
|
The script you've got here won't work because it is missing semi-colons, as another poster suggested:
If you are going to put it into a script and not run it from the command line, then you can break it up so it is easier to read:
Note that this way, you don't need to include the semi-colons, because multiple commands aren't on the same line. Good luck, --jed answered 18 Apr '10, 03:16 jeddaniels |
You can enter a multiline command at the shell prompt. The shell will prompt with $PS2 until the command is complete:
The '!' in double quotes might cause a problem due to the ridiculous practice of using a printing character for something other than printing the character. I prevent it by setting $histchars to the emptry string in ~/.bashrc answered 01 Mar '13, 06:44 cfajohnson |
Does it have to be a bash script? Maybe a PERL script would work better? answered 17 Apr '10, 03:29 BaldGuyKen |
i think try while condition is the best for your case answered 22 Apr '10, 07:19 Network Syst... |
There are a couple of solutions to the exclamation mark: For some strange reason, bash will not delete a backslash that quotes the exclamation mark when inside double quotes. answered 02 Mar '13, 19:57 darkonc |
Are you sure /vol/USBDISKB is the mountpoint? Try this to see:
Another option is to use the mountpoint command instead of brackets:
Or just:
answered 07 Nov '13, 07:05 KenJackson |
One thing - if you are running such an old version of Ubuntu, at least subscribe to security mailing lists so you can keep the holes from being too great.
Please accept an answer so the question/answer can be finished. Or provide more details so we can help.