|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash script
1) #!/bin/bash -p
What is -p means ? 2) killall dhcpcd > dev/null 2 > & 1 What is 2 > & 1 means ? 3) if [ $? -ne 0 ] then ifconfig eth0 up; exit 1; fi What is "$?" ? Does it refer to the last variable reference ? 4) suid putdata update && What is && means ? I did look at the web site that gives instruction on BASH programming, but some of the things mentioned above was not covered. |
|
#2
|
||||||
|
||||||
|
Re: Bash script
Quote:
I checked the man page on that and did not find that option. I did find a --posix option that might be equivalent. You should do a web search on bash and -p to see what you can find. If the archaic K&R syntax in your other post is any indication, this -p option might also be archaic. Quote:
It means to redirect stderr to the same place you redirected stdout. That's a real handy notation that I wish worked in DOS. Quote:
That's a predefined special environment variable, which in this case is the exit code of the previous command/process. So this statement says that if the previous command failed (0 means it ran successfully), then bring the ethernet interface back up and exit with a non-zero exit code to indicate failure. BTW, that is why your C programs should always return an int: zero if successful (using return 0; ) and non-zero if an error was encountered (using something like exit(1) ). There's an entire set of these special variables; eg: $$ == the current process id $? == the exit code of the previous process $# == the number of parameters passed to this process; just like argc $* == the argument list -- there are two different variables for this that handle quoting differently, so you'd better research this one. perl uses many of the same special variables, plus many more. Quote:
This one I'm not at all sure. You'd better do a web search on suid and "&&". Are you sure that it's "&&" and not "$$"? Last edited by dwise1_aol : June 26th, 2003 at 05:24 PM. |
|
#3
|
||||
|
||||
|
&& is a logical AND and is often used to decouple, or serialise commands at the bash promt, as in
# ./configure && make ie if the first process (left hand side of &&) fails, then the system won't evaulate the right hand side of the expression. This all implies that there could be a missing command on the end of this last example... just a thought christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Dotcut alerts: Online Press cuttings / news alerts Clearprop: UK microlight school, wiltshire Uk dating: UK safe dating with Topdates About Christo . . |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Bash script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|