Poke a Shell Variable with xTalk?

Sivakatirswami katir at hindu.org
Wed Sep 14 23:33:30 EDT 2005


OK more digging... I am very close...(after 10 hours or more on  
this...) more simple than I thought

"echo" is your friend!   Only now, a new problem, end lines on the  
Mac. I am unable to enforce them by any means.

-----------------
put "Subject: Rev Rocks" & cr \
& "From: Innovative_Geologists at xTalkQuarry.com" & cr \
& "To: AnyoneWhoLikesPerl at LostInCyberSpace.com" & cr  \
& "Subject: Try It... You will be Happy You Did!" & cr & cr
&"Get more done with few lines of code than you will ever imagine  
possible." into tMsg


put tMsg into $DailyEmail
set the shellcommand to "/bin/sh"
put "echo $DailyEmail" into tCmd
put shell(tCmd)

result:

Subject: Rev Rocks From: Innovative_Geologists at xTalkQuarry.com To:  
AnyoneWhoLikesPerl at LostInCyberSpace.com Subject: Try It... You will  
be Happy You Did! Get more done with few lines of code than you will  
ever imagine possible.

# no line breaks!

OK try this now (the old standby if writing a file that some Nix  
program needs to handle:)

put "Subject: Rev Rocks" & cr \
& "From: Innovative_Geologists at xTalkQuarry.com" & cr \
& "To: AnyoneWhoLikesPerl at LostInCyberSpace.com" & cr  \
& "Subject: Try It... You will be Happy You Did!" & cr & cr
&"Get more done with few lines of code than you will ever imagine  
possible." into tMsg

replace char (13) with char(10) in tMsg


put tMsg into $DailyEmail
set the shellcommand to "/bin/sh"
put "echo $DailyEmail" into tCmd
put shell(tCmd)

Same result: no line breaks:

Subject: Rev Rocks From: Innovative_Geologists at xTalkQuarry.com To:  
AnyoneWhoLikesPerl at LostInCyberSpace.com Subject: Try It... You will  
be Happy You Did! Get more done with few lines of code than you will  
ever imagine possible.

but if I write tMsg to a file and read that file and put tFile I will  
get

Subject: Rev Rocks
From: Innovative_Geologists at xTalkQuarry.com
To: AnyoneWhoLikesPerl at LostInCyberSpace.com
Subject: Try It... You will be Happy You Did!

Get more done with few lines of code than you will ever imagine  
possible.

so,

put "echo $DailyEmail | sendmail hpi.list at hindu.org katir at hindu.org"   
into tCmd

does what I wanted to do (pipe a variable from a Transcript script  
into a shell script, and then from StnOut to StnIn to fooProcess)   
but no end lines and sendmail is not happy at all... this the whole  
thing is the Subject....

??

Sivakatirswami










On Sep 14, 2005, at 3:37 PM, Sivakatirswami wrote:

> Jim, interesting, though I'm not much closer to a solution with  
> this, it did prompt me to "think different" find another way to  
> state the question.  In OSX we have "open process" but we can't do  
> that for Unix process on the same box except through shell..
>
> Now on our Linux web server I use this CGI for sending mail from  
> remote rev Apps, where those apps have no mail services, but simple  
> POST a msg to the web server... Now, if I could just "translate"  
> this to work from inside a stack on OSX, we would have it.  Or I  
> might just use this CGI as is and put this CGI on an internal web  
> site on our inhouse OSX Serve... but such a hack!   I would rather  
> be able to do this directly from any box...
>
> ########
>
> #!/usr/local/bin/revolution
>
> ## This little CGI simply avoids the need to install an SMTP library
> ## on any client rev app. Instead, I just have the client app build  
> a post
> ## string, parse that and let my server's send mail do the rest.
> ## the TO is hard coded, but obviously doesn't need to be.
> ## this saves a lot of headaches debugging email services in a rev  
> client app.
> ## and you can do other stuff with this if you want, log it, poke a  
> dbase etc.
>
> on startup
> if $REQUEST_METHOD is "POST" then
>   repeat until length(tDataIn) >= $CONTENT_LENGTH
>     read from stdin until empty
>     put it after tDataIn
>   end repeat
> split tDataIn by "&" and "="
>
> ## the following is what I've been trying to emulate from the  
> "console" version of Rev
> ##  without success...
>
> put "/usr/sbin/sendmail -t" into mprocess
>         open process mprocess for write
>         write "From:" && (urlDecode (tDataIn["from"]))& cr to  
> process mprocess
>         write "To:" &&   "katir at hindu.org"  &  cr to process mprocess
>         write "Subject:" &&   (urlDecode (tDataIn["subject"]))   &   
> cr & cr to process mprocess
>        write    (urlDecode (tDataIn["body"])) &  cr to process  
> mprocess
>        close process mprocess
>        put the result into tResponse
>
> ## in case this is being done from a web form then send back the  
> response to port 80
>
>     put "Content-Type: text/html" & cr
>     put "Content-Length:" && the length of tResponse & cr & cr
>     put tResponse
>
> end if
> end startup
>
>
>
>
>
> On Sep 13, 2005, at 4:10 PM, Jim Ault wrote:
>
>
>> This may help, then again, maybe it does not apply to your situation
>>
>> http://developer.apple.com/technotes/tn2002/tn2065.html
>>
>> Q: How long can my command be, really?
>>
>> A: Calling do shell script creates a new sh process, and is therefore
>> subject to the system’s normal limits on passing data to new  
>> processes: the
>> arguments (in this case, the text of your command plus about 40  
>> bytes of
>> overhead) and any environment variables may not be larger than  
>> kern.argmax,
>> which is currently 262,144 bytes. Because do shell script inherits  
>> its
>> parent’s environment (see the next question), the exact amount of  
>> space
>> available for command text depends on the calling environment. In  
>> practical
>> terms, this comes out to somewhat more than 261,000 bytes, but  
>> unusual
>> environment settings might reduce that substantially.
>> Note: This limit used to be smaller; in Mac OS X 10.2 it was about  
>> 65,000
>> bytes. The shell command sysctl kern.argmax will give you the  
>> current limit
>> in bytes.
>>
>> On 9/13/05 6:36 PM, "Sivakatirswami" <katir at hindu.org> wrote:
>>
>>
>>
>>> OK the above works, but I want to try now piping tMsg straight into
>>> Send mail *without* saving or reading a file from the hard drive
>>> (why? some new security thing in OSX, Postfix preventing more than
>>> 1024 chars input without introducing a CRLF... even right in the
>>> middle of a word, I'm getting a space in the middle of a word in the
>>> HTML version a complete bad line break in the middle of a word  
>>> (every
>>> 1024 chars) in the text alternative)
>>>
>>>
>>
>> or maybe you need to interact with the process directly as in
>>
>> Q: I have started a background process; how do I get its process  
>> ID so I can
>> control it with other shell commands?
>>
>> A: You can use a feature of sh to do this: the special variable $!  
>> is the ID
>> of the most recent background command, so you can echo it as the last
>> command in your shell script, like this:
>> do shell script "my_command &> /dev/null & echo $!"
>> -- result: 621
>> set pid to the result
>> do shell script "renice +20 -p " & pid
>> -- change my_command's scheduling priority.
>> do shell script "kill " & pid
>> -- my_command is terminated.
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the Use-livecode mailing list