Re: How to write IF Else condition inRunsShellScript component?
Steve Loughran <[email protected]> Mon, 19 Feb 2007 20:51:05 +0000
| Newsgroups | gmane.comp.java.smartfrog.devel |
|---|---|
| Message-ID | <[email protected]> |
Goldsack, Patrick wrote:
> There are two ways in which you might enter this command:
>
> firstly as a multi-line string (should work, but I haven't tried it),
>
> ##
> if [ -s /tmp/list ]
> then
> echo "Not empty"
> else
> echo "Empty"
> fi
> #
>
> the second as a single line using ; as a separator for the lines and
> escaping "
>
> "if [ -s /tmp/list ] ; then echo \"Not empty\"; else echo \"Empty\"; fi"
>
> Patrick
I'm not sure you need to resort to shell script for this, though the
exact meaning of the -s test escapes me. Are you looking for a file
existing, b
There is run-time conditions in the workflow components, whiich exists
to let you test for or block for dynamic changes in external state.
-Any component that implements the Condition interface has a remote
method evaluate() that evals to true or false
-This component can be deployed inside any compound that wants to
evaluate conditions, of which we have
If, WaitFor and LivenessTest -the latter evaluates the condition every
time it receives an sfPing() method, so you can define system health in
any set of conditions. Waitfor blocks until a state is reached; I may
add a While() that terminates its action when a condition fails, and a
During which is a While with the feature that it redeploys its child
when the condition is met again. This would let you undeploy something
when the network went away, and bring it back up when things improve.
If {
condition extends True;
then extends Echo {
message "not empty";
}
else extends Echo {
message "empty";
}
What conditions we have is
-True, False, And, Or, Not, Xor (And and Or are shortcutting)
-Some conditions in the test framework (test components are all
conditional)
-Database connectivity and a MySql specific ping.
-a HostExists condition in the www module that looks for hostnames
resolving.
There isnt a FileExists condtion, yet it was clearly on the roadmap. I
will put together one quickly. In the meantime, know that the File
component has some attributes which let you declare that a file must
exist, and /or that it must be a directory. So you can fail a deployment
if something is missing or a dir.
this is what I have planned in the workflow/conditions/components.sf file:
FileExists //file exists (plus min size)
Presumably that would work for you?
-stve
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV