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

Mariano Martinez Peck marianopeck at gmail.com
Tue Jan 14 08:03:40 PST 2014


On Tue, Jan 14, 2014 at 1:01 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

>
>>
>> Mariano,
>>
>> that should be correct and it works for me. I tested with the following
>> two scripts:
>>
>> test.sh with the following lines:
>>
>> #!/bin/bash
>> topaz -ql <<EOF
>> input $1
>> EOF
>>
>>
>> and input.topaz like this:
>>
>> set gems seaside user DataCurator pass swordfish
>> login
>> printIt
>> 20 factorial
>> %
>>
>> I can execute "bash test.sh input.topaz" and get the result.
>>
>>
> OK, that works for me. But...is there a way I can for example, get
> something like this: I would like to access the parameters from input.topaz
> script. For example:
>
> set gems seaside user DataCurator pass swordfish
> login
> printIt
> $2 factorial
> %
>
> And then call it like this:
>
>  "bash test.sh input.topaz 20"
>
> I would like to do that without having to export each variable
> individually...  maybe using $@ somewhere?
>
>


I forgot to said....somehow that works for startSeaside30_Adaptor.... but I
don't understand how it can do it.




>
>
>> Just as addition and independent of the here documents approach: Another
>> way to access the shell script arguments would be to export them to the
>> environment and access them via System>>gemEnvironmentVariable:. So the
>> following should also work:
>>
>> #!/bin/bash
>> export MYARG=$1
>> topaz -l <<EOF
>> set gems seaside user DataCurator pass swordfish
>> login
>> printIt
>> 'The first argument was: ', (System gemEnvironmentVariable: 'MYARG')
>> %
>> exit
>> EOF
>>
>>
> Ok,  (System gemEnvironmentVariable: 'MYARG') is answering nil ...
> however.....System performOnServer: 'echo $MYARG'  does answer correctly.
> weird...
>
>
>
>>  The here document is just to make the example complete. This way you can
>> access the env vars from within any method.
>>
>>
> Thanks!!
>
>
>
>>  Br,
>> Ralph
>>
>>
>>
>>  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
>>
>>
>>
>> _______________________________________________
>> Glass mailing list
>> Glass at lists.gemtalksystems.com
>> http://lists.gemtalksystems.com/mailman/listinfo/glass
>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>



-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20140114/8eca31c4/attachment-0001.html>


More information about the Glass mailing list