[Glass] run topaz from bash and have access to arguments from topaz smalltalk
Mariano Martinez Peck
marianopeck at gmail.com
Tue Jan 14 05:57:28 PST 2014
On Tue, Jan 14, 2014 at 4:27 AM, Ralph Mauersberger <
ralph.mauersberger at ewetel.de> wrote:
> Hi Mariano,
>
> to access the arguments from inside topaz you can use a feature of most
> unix shells called "here document". This concept allows you to embed a
> document inside your shell script which gets passed to stdin of any
> executable:
>
> executable <<LimitString
> firstCommand
> nextCommand $1
> LimitString
>
> The document is surrounded by any given string. The shell itself will
> substitute the environment variables and replace them by there values
> before the document is passed to the executable.
>
>
Hi Ralph, thanks for the explanation. So indeed, it seems that is what is
being used by startSeaside30_adaptor which does:
cat << EOF | nohup $GEMSTONE/bin/topaz -l -e $4 2>&1 >>
$GEMSTONE_LOGDIR/${1}_server-${2}.log &
> So use something like the following:
>
> #!/bin/bash
>
> if [ -z \$1 ];
> then
> echo "argument expected"
> fi
>
> topaz -l <<EOF
> set gems $STONENAME user Username pass TopSecret
> login
> printIt
> '$1' printString
> %
> exit
> EOF
>
>
OK, that worked and gets what I want. But....I am unable to apply the same
"Here Document" approach to my real needs:
cat ../scripts/login.st \$1 | su -m $GEMSTONE_USER -c \"$GEMSTONE/bin/topaz
-ql -T200000 \"
Notice that $1 is the topaz script I send as an argument (yes, it can have
a EOF at the end). Also, I am executing topaz with a "su -m -c ..." so that
changes the things I guess.
Do you know how can I adapt the above line to use the Here Document
features? I would like to access the arguments inside the topaz script sent
as argument ($1 in this case).
>
> You used "run" inside your script which is a normal "do-it". I replaced it
> by "printIt" because I assume that you are interessted in the evaluated
> expression.
>
>
yes, thanks :)
> Topaz has a directive called input. Use that to load other code or if you
> don't like the login credentials hardcoded in the script:
> input $MYAPP_CONFIG/mylogin.topaz
>
>
mmm good idea.
So...to conclude:
/opt/gemstone/product/bin/topaz -ql -T200000 <<EOF
login
printIt
'$1' printString
%
exit
EOF
that works. But if I do exactly the same but in the file passed as
argument, it does not work anymore:
/opt/gemstone/product/bin/topaz -ql -T200000 <<EOF
input $1
EOF
Any ideas?
Thank!
Hope that helps.
>
> Br,
> Ralph
>
>
>
> Am 13.01.2014 15:31, schrieb Mariano Martinez Peck:
>
> Hi guys,
>
> In Norbert's utilize, we have this nice script runTopazScript.sh :
>
> #!/bin/sh
>
> source $APPLICATION_DIR/env
>
> if [ -z \$1 ];
> then
> echo "no script name given"
> fi
>
> cat ../scripts/login.st \$1 | su -m $GEMSTONE_USER -c
> \"$GEMSTONE/bin/topaz -ql -T200000 \"
>
>
> That let us automatically connect to GemStone using an auto-generated
> .topazini. So we can pass around a topaz script and that would be execute.
> So we can do for example:
>
> sudo sh ./runTopazScript.sh something.tpz
>
> Now....I saw in several topaz scripts from seaside that the SMALLTALK
> code is able to directly access the argument variables to the shell. For
> example, startSeaside30_adaptor does:
>
> GsFile gciLogServer: '$1 Server started on port ', $2 printString.
>
> I want to do the same in my something.tpz. Imagine I have this
> something.tpz file:
>
> run
> $1 printString.
> %
>
> And I execute:
>
> sudo sh ./runTopazScript.sh something.tpz mariano
>
> So how can we adapt the script so that such a smalltalk script outputs
> 'mariano' instead of the literal string $1 ?
>
> I tried adding a & at the end of the topaz call and many other
> workarounds but I am not sure if topaz needs something special for this.
>
>
> Thanks a lot in advance and sorry for the offtopic.
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
> _______________________________________________
> Glass mailing listGlass at lists.gemtalksystems.comhttp://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
>
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
--
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20140114/72dec8c0/attachment.html>
More information about the Glass
mailing list