[Glass] run topaz from bash and have access to arguments from topaz smalltalk

Ralph Mauersberger ralph.mauersberger at ewetel.de
Mon Jan 13 23:27:32 PST 2014


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.

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


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.

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

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 <http://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 list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20140114/d15ba423/attachment.html>


More information about the Glass mailing list