[erlang-questions] escript question

Chris Hicks silent_vendetta@REDACTED
Sun Sep 18 23:15:01 CEST 2011


I was thinking about this some more, and doing some more reading, and if I have a process which uses os:cmd on a unix box to run the escript and if doing so starts up a full Erlang node, is there any reason that the Pid of the calling process couldn't be passed as one of the arguments? Couldn't the script simply send a message to that Pid and once the script exits and returns a value to the process that called os:cmd, that process would then do a receive to retrieve the message?
On a related note, can an escript be run as a text string instead of a file residing on the system? Basically, I'm trying to figure out if I can just hold all my scripts in a DB, pull them out as needed and execute them rather than actually creating a file that is run.
From: silent_vendetta@REDACTED
To: watson.timothy@REDACTED
Date: Sun, 18 Sep 2011 10:57:24 -0700
CC: erlang-questions@REDACTED
Subject: Re: [erlang-questions] escript question








Thanks for the response, Tim. The first two were along the lines of what I was thinking I'd need to do, though I didn't know about file:consult/1 which could come in very handy for a couple other things I'm working on. I'm leaning a bit more towards #1 though simply because in the system I'm building there could be anywhere from dozens to hundreds of these scripts being fired off each second and, without having spent much time thinking about it, I imagine trying to filter the appropriate structure back to the appropriate process which fired off the escript via method #2 would just add some unnecessary complexity.
Date: Sun, 18 Sep 2011 18:44:24 +0100
Subject: Re: [erlang-questions] escript question
From: watson.timothy@REDACTED
To: silent_vendetta@REDACTED
CC: erlang-questions@REDACTED

1. write it to a file and use file:consult/1 to grab the result.2. write it back to stdout and use erl_parse/erl_eval3. use emu_args to get the escript hooked into the distribution protocol and use rcp:call to send the result back

Not actually sure about (3) as I've never done that, but the other two work fine and are simple to implement.
Cheers,
Tim


On 18 September 2011 17:49, Chris Hicks <silent_vendetta@REDACTED> wrote:






Quick question, what would be considered the easiest way to "return" data to a running Erlang application from an escript? For example I might want to run an escript with a data structure I want it to modify and, once it is all done, get the modified structure back. 		 	   		  


_______________________________________________

erlang-questions mailing list

erlang-questions@REDACTED

http://erlang.org/mailman/listinfo/erlang-questions



 		 	   		  

_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://erlang.org/mailman/listinfo/erlang-questions 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110918/0342d2c6/attachment.htm>


More information about the erlang-questions mailing list