Page 1 of 1

Problems with command line app

Posted: Sat Sep 05, 2015 4:34 pm
by andrewferguson
Hello,

I am trying to make an application that takes a Scratch project (https://scratch.mit.edu/) and converts it into another programming language (PAWN). I have completed everything, but have now run into a problem when deploying this application. The application will be running on a server, so it needs to run as a command line app.

Problem 1: 'put url' not working

The first part of the code is to retrieve the JSON data from the Scratch project and store it in a variable so it can then be read by other parts of the program. This part takes in two parameters: the ID of the scratch project which is used to get the JSON from the Scratch API, and a random ID which will be used to identify the build logs throughout later processes. This is the first part's code:

Code: Select all

global scratchData, rndID

on startup
   log $1 & $2 
   put $1 into s1
   put $2 into s2
   put ("http://projects.scratch.mit.edu/internalapi/project/" & $1 & "/get/") into scratchURL
   log scratchURL
   put url scratchURL into scratchData
   log scratchData
   put $2 into rndID
   if char 1 of rndID is space then put empty into char 1 of rndID
end startup

on log ttt
   put the specialFolderPath of "Desktop" & "/t.txt" into tt
   open file tt for append
   write return & ttt to file tt
   close file tt
end log
When the app is build and run from the command line as ./appName -ui 75043190 xxx, the result in the log file is:

Code: Select all

75043190xxx
http://projects.scratch.mit.edu/internalapi/project/75043190/get/
The URL outputted to the log file is valid, and yet 'put url' does not work. In addition, if I change the above script so that instead of $1 and $2, paramiters are passed through, and type 'startup "75043190", "xxx"' into the message box, everything works. Does anyone know why this is and how to fix it?

Problem 2: LiveCode-built standalone does not run on the server

The next problem occurs when I take the build app and try to run it on my VPS. I get the message:
./appName : File or Directory not found.
The app *is* there, I can view it through ls, but for some reason it does not let me run it. Any help with this? My only thought would be to install a GUI and then LiveCode on the server, so I could try and 'Save as Standalone Application..' on the server, in case this made a difference. The server is running 64-bit Linux, and the laptop I am using to develop the app also runs 64-bit Linux.

Thanks for any help,
Andrew

Re: Problems with command line app

Posted: Mon Sep 07, 2015 6:50 pm
by Klaus
Hi Andrew,

Livecode uses a coupe of libraries e.g. for internet stuff and they have not yet been loaded "on startup".
So I think this is why "put URL..." does not work. And at that point the script silently fails with an "un-catched" error.

Sorry, no idea about server stuff.


Best

Klaus

Re: Problems with command line app

Posted: Tue Sep 15, 2015 12:07 pm
by MaxV
andrewferguson wrote:Hello,

I am trying to make an application that takes a Scratch project (https://scratch.mit.edu/) and converts it into another programming language (PAWN). I have completed everything, but have now run into a problem when deploying this application. The application will be running on a server, so it needs to run as a command line app.

Problem 1: 'put url' not working

The first part of the code is to retrieve the JSON data from the Scratch project and store it in a variable so it can then be read by other parts of the program. This part takes in two parameters: the ID of the scratch project which is used to get the JSON from the Scratch API, and a random ID which will be used to identify the build logs throughout later processes. This is the first part's code:

Code: Select all

global scratchData, rndID

on startup
   log $1 & $2 
   put $1 into s1
   put $2 into s2
   put ("http://projects.scratch.mit.edu/internalapi/project/" & $1 & "/get/") into scratchURL
   log scratchURL
   put url scratchURL into scratchData
   log scratchData
   put $2 into rndID
   if char 1 of rndID is space then put empty into char 1 of rndID
end startup

on log ttt
   put the specialFolderPath of "Desktop" & "/t.txt" into tt
   open file tt for append
   write return & ttt to file tt
   close file tt
end log
When the app is build and run from the command line as ./appName -ui 75043190 xxx, the result in the log file is:

Code: Select all

75043190xxx
http://projects.scratch.mit.edu/internalapi/project/75043190/get/
The URL outputted to the log file is valid, and yet 'put url' does not work. In addition, if I change the above script so that instead of $1 and $2, parameters are passed through, and type 'startup "75043190", "xxx"' into the message box, everything works. Does anyone know why this is and how to fix it?
Put URL works.
Try to add in startup message this code:
answer ("$ = " & $1 & CR "$2= " & $2 & CR & "$3= " & $3)


andrewferguson wrote: Problem 2: LiveCode-built standalone does not run on the server

The next problem occurs when I take the build app and try to run it on my VPS. I get the message:
./appName : File or Directory not found.
The app *is* there, I can view it through ls, but for some reason it does not let me run it. Any help with this? My only thought would be to install a GUI and then LiveCode on the server, so I could try and 'Save as Standalone Application..' on the server, in case this made a difference. The server is running 64-bit Linux, and the laptop I am using to develop the app also runs 64-bit Linux.
This should be just a path issue. Use an absolute path.