BASH function using if,then,else
Hi,
I am trying to build a function insode a script. If some one could tell me how I can do this I would appreciate it. Code:
#!/bin/sh SEE>> Code:
for c in $ISO Any how, thanks for any help in advance. |
Greetings!
You're *really* close Code:
for c in $( echo ${ISO} ) P.P.S: If this script runs as root, you might want to consider using the absolute path to any binaries you call. Jokers tend to leave little scripts in a filesystem named "ls" that contain "rm -rf $@" |
Well that joker would be a real douche I would think.
|
Well the joker would be a douche wouldnt he. I mean to wipe a directory like that on someone. Any way.
So, could you tell me why the if, then, else statements are working? For some reason when conditions in if are not met, the script still runs as if they had been met. See below: Code:
./Documents/new.set.script.sh: 73: [-f: not found Code:
test: 73: -lt: argument expected |
Quote:
The problem with absolute paths is they are not portable across systems that have executables in different directories. One solution is to put the names in variables (for example ls=/bin/ls) so they can be changed in one place. That's still cumbersome and requires modifying the script to work on a variety of systems. Perhaps the best solution (for security and to set up a defined shell execution environment) is for the script to set its own PATH, for example export PATH=/usr/bin:/bin |
Quote:
BTW [[ ... ]] is more robust than [ ... ] for reasons explained here. |
well all i want to do is create a folder with some files in it. Why does the script continue to elif in my script if the folder /etc/firewall does not exist? I thought thats what the starting if statement was looking for. if [-f some.file] is not found, then what ever commands are under else would be ran. No?
|
Quote:
BTW test, [ ... ] and [[ ... ]] are functionally similar; for clean coding you can pick one ([[ .. ]] is recommended) and use only that one. |
All times are GMT -5. The time now is 07:38 PM. |