Skip to main content
Roy Marshall
Known Participant
September 30, 2011
Answered

Getting data from SQL database

  • September 30, 2011
  • 3 replies
  • 6581 views

Hi

I am stil trying to get some basic information stored in a database table on my SQL Server.

I can do this by embedding an Applescript do carry out the shell command 'curl' as below:

myFullScriptString = "do shell script \"curl -0  localhost/asset.php?asset_id="+assetID+"\"";

myForceError = app.doScript(myFullScriptString, ScriptLanguage.APPLESCRIPT_LANGUAGE);

return(myForceError);

but I dont want to be limited to OSX.

Is there a way this can be put into a native socket comment using a structure as below?

reply = "";

conn = new Socket();

conn.open("192.168.91.184:8888");

conn.write(" GET /myfile.php?" + variousVariable + " HTTP/1.0\n\n");

reply = conn.read(999999);

conn.close;

Cheers

Roy

This topic has been closed for replies.
Correct answer John Hawkinson

conn.write(" GET /getassetstatus.php?enc=10.1.1.234~38~11~13446~PASSWORD");


I dont know what the "GET" does, and the code I used as a base had "HTTP/1.0\n\n" at the end of the url.

With all my tests, the variable reply is always empty.

You need the <SPACE>HTTP/1.0\n\n! Why did you take it out? Check the protocol spec, http://www.ietf.org/rfc/rfc2616.txt.

You also have a leading space that looks wrong. So:

conn.write("GET /getassetstatus.php?enc=10.1.1.234~38~11~13446~PASSWORD HTTP/1.0\n\n")

3 replies

Roy Marshall
Known Participant
October 10, 2011

This question is being continued in http://forums.adobe.com/message/3963484#3963484

SuperMacGuy
Known Participant
October 7, 2011

I don't want to muddy things up, but if you want some other options for OSX, I've been using some scripts and frameworks to talk to an MS-SQL db, and it should work for some other SQL db's also. Send me a PM if interested.

John Hawkinson
Inspiring
October 1, 2011

Hmm, the dangers of answering threads in reverse chronological order. Apparently you are familiar with the Socket api.

Something like that should work, yes.

But your question is quite oddly phrased. I assume you've tried that and it does not work [else why would you be posting]? But you do not tell us how it fails!

How does it fail?

Roy Marshall
Known Participant
October 2, 2011

Hi.

I have spent some  time playing with the code below:

reply = "";

conn = new Socket();

conn.open("localhost:80");

conn.write(" GET /getassetstatus.php?enc=10.1.1.234~38~11~13446~PASSWORD");

reply = conn.read(999999);

conn.close;

where the php file on my computer "getassetstatus.php" takes the string, and returns a number.  This works when being passed as a curl commend 2 layers deep inside doScript, but I want to take out the Applescript dependancy.

I dont know what the "GET" does, and the code I used as a base had "HTTP/1.0\n\n" at the end of the url.

With all my tests, the variable reply is always empty.

If anyone can help, I would be grateful.

Cheers

Roy

John Hawkinson
John HawkinsonCorrect answer
Inspiring
October 2, 2011

conn.write(" GET /getassetstatus.php?enc=10.1.1.234~38~11~13446~PASSWORD");


I dont know what the "GET" does, and the code I used as a base had "HTTP/1.0\n\n" at the end of the url.

With all my tests, the variable reply is always empty.

You need the <SPACE>HTTP/1.0\n\n! Why did you take it out? Check the protocol spec, http://www.ietf.org/rfc/rfc2616.txt.

You also have a leading space that looks wrong. So:

conn.write("GET /getassetstatus.php?enc=10.1.1.234~38~11~13446~PASSWORD HTTP/1.0\n\n")