RE: tempFile & shell component
"Guijarro, Julio" <[email protected]>
| Newsgroups | gmane.comp.java.smartfrog.user |
|---|---|
| Message-ID | <8D5B24B83C6A2E4B9E7EE5FA82627DC9C1A327@sdcexcea01.emea.cpqcorp.net> |
Sorry Andreas, I did write the solution from the top of my head.
The problem that you have now is that I put the LazyConcat as a child
for BashShellScript and BashShellScript reads the command during its
deploy phase and the child is not ready yet because of Compound
lifecycle.
Here is the right solution, in witch all the three components are
orchestrated in the right order:
#include "org/smartfrog/components.sf"
#include "org/smartfrog/services/utils/concat/components.sf"
#include "org/smartfrog/services/filesystem/components.sf"
#include "org/smartfrog/services/os/runshell/components.sf"
sfConfig extends Compound {
testFile extends TempFileWithCleanup {
dir "/tmp";
prefix "tempfile.txt";
text "foo";
}
command extends LazyConcat {
string extends LAZY {
a "ls ";
b LAZY testFile:filename;
}
}
testCmd extends BashShellScript {
processName "test";
cmd LAZY command:concat;
logLevel 5; // 5 all errors, -1 none
printStack true; //default false;
}
}
Just one more thing. There is now a better component for shell scripting
and it will replace the old "runShell" component:
#include "org/smartfrog/services/shellscript/components.sf"
The documentation for it is attached.
Julio Guijarro
> -----Original Message-----
> From: Andreas Unterkircher [mailto:[email protected]]
> Sent: 28 June 2005 13:45
> To: Guijarro, Julio
> Cc: smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject: RE: [Smartfrog-support] tempFile & shell component
>
>
> Hello Julio,
>
> thank you for the hint. Unfortunately it still doesn't work: according
to
> your advice I try the following
>
> #include "org/smartfrog/components.sf"
> #include "org/smartfrog/services/utils/concat/components.sf"
> #include "org/smartfrog/services/filesystem/components.sf"
> #include "org/smartfrog/services/os/runshell/components.sf"
>
> sfConfig extends Compound {
>
> testFile extends TempFileWithCleanup {
> dir "/tmp";
> prefix "tempfile.txt";
> text "foo";
> }
>
> testCmd extends BashShellScript {
> processName "test";
> string1 extends LazyConcat {
> string extends LAZY {
> a "ls ";
> b LAZY testFile:filename;
> }
> }
> cmd LAZY string1:concat;
> }
> }
>
> But this gives:
>
> 2005/06/28 14:40:19:274 CEST [DEBUG][RMI TCP
Connection(2)-137.138.38.90]
> HOST oplabox03.cern.ch:rootProcess:test1 - creating temp file in dir
> [/tmp] prefix=tempfile.txt suffix=null
> [defaultRunShell(bash)] LOG > Reference not found, SFRunShell, 2
>
> I think the problem stems from "cmd LAZY string1:concat".
>
> Best regards,
> Andreas
>
> On Tue, 28 Jun 2005, Guijarro, Julio wrote:
>
> > Hi Andreas,
> >
> > The "Concat" has to happen at runtime because the filename does not
> > exist until then. For that you need to use a component that offers
> > similar functionality: LazyConcat. Lazy concat will create a runtime
> > attribute called "concat" that will have the concatenation of all
the
> > attributes contained inside its "string" attribute.
> >
> >
> > Try
> > #include "org/smartfrog/services/utils/concat/components.sf"
> >
> > > testCmd extends BashShellScript {
> > > processName "test";
> > string1 extends LazyConcat {
> > string extends LAZY {
> > a "dir ";
> > b LAZY testFile:filename;
> > }
> > }
> > cmd LAZY string1:concat;
> > }
> >
> > Julio
> >
> > > -----Original Message-----
> > > From: smartfrog-support-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:smartfrog-
> > > [email protected]] On Behalf Of Andreas
Unterkircher
> > > Sent: 27 June 2005 16:30
> > > To: smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > > Subject: [Smartfrog-support] tempFile & shell component
> > >
> > >
> > > Hello,
> > >
> > > I would like to use the TempFileWithCleanup component in
conjunction
> > with
> > > a BashShellScript component. E.g. something like:
> > >
> > > sfConfig extends Compound {
> > >
> > > testFile extends TempFileWithCleanup {
> > > dir "/tmp";
> > > prefix "tempFile.txt";
> > > text "foo";
> > > }
> > >
> > > testCmd extends BashShellScript {
> > > processName "test";
> > > string1 LAZY ATTRIB testFile:filename;
> > > cmd extends concat {
> > > a "ls -l";
> > > b string1
> > > }
> > > }
> > >
> > > The should list the temporary file (wich gets created in the
sfDeploy
> > > phase of the TempFileWithCleanup component). The above example
doesn't
> > > work; I played around a little bit but I could not figure out how
to
> > > access the "filename" field so that I can use with the shell
> > component.
> > > How one could do that ?
> > >
> > > Thanks,
> > > Andreas
> > >
> > >
> > > -------------------------------------------------------
> > > SF.Net email is sponsored by: Discover Easy Linux Migration
Strategies
> > > from IBM. Find simple to follow Roadmaps, straightforward
articles,
> > > informative Webcasts and more! Get everything you need to get up
to
> > > speed, fast.
http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> > > _______________________________________________
> > > Smartfrog-support mailing list
> > > Smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > > https://lists.sourceforge.net/lists/listinfo/smartfrog-support
> >
sfShellScript.pdf
(application/octet-stream, 197.2 KB) - not displayed