I have the following code which is intended to launch a console app running in a Xojo Cloud environment.
[code] dim worker as folderItem
if DebugBuild then
worker = specialFolder.Desktop.child(“Text-Me-Web-Folder”).child(“ProjectAlpha”)
else
worker = SpecialFolder.SharedDocuments.child(“ProjectAlpha”)
end if
dim cmd as string
dim ret as string = EndOfLine
cmd = "cd " + worker.ShellPath + ret // this is the yikes moment …
cmd = cmd + “./PretendParse” + ret
//tbs is a shell, property of the page. Instantiated elsewhere with mode = 1 and timeout = -1
if not tbs.IsRunning then
taSyslog.AppendText "ExecCmd: " + cmd + EndOfLine
tbs.execute(cmd)
else
taSyslog.AppendText "WriteCmd: " + cmd + EndOfLine
tbs.write(cmd)
tbs.write(EndOfLine)
end if[/code]
When run in the debugger, the SpecialFolder resolves to the place one would expect, and the console app it targets … runs.
When deployed to Xojo Cloud, the SpecialFolder resolves to:-
I am moderately certain that I don’t have example.com anywhere in my code.
I presume that ShellPath puts it in there for some reason … but I am sufficiently egotistical to think this might be a bug.
Thank you for your thoughts.
James, yes it is mapped differently !
I have previously used folderItems within Xojo Cloud to good effect. They Just Work.
However, the folderItem.shellPath, folderItem.AbsolutePath, and folderItem.UnixPathMBS all map to
/home/sites/www.example.com/…
so it is something else.
I have stopped using SpecialFolder, with some misgivings to be sure, and attempted hard coding the path.
One thing you should look at is the page for SpecialFolder in the language reference. You’ll notice that most of the mappings don’t work, including “desktop” as there’s no GUI on a Xojo cloud server.
Well, thank you Greg. Yes I was aware that most of the SpecialFolder mappings do not work … but Shared_Documents is listed as working.
Did you have any idea how I can, using a shell from within my CGI web app, launch a console app that lives within the folder
/Shared_Documents/TMW-Alpha/
and is called PretendParse.
My present effort using a shell involves cd’ing to the directory /Shared_Documents/TMW-Alpha/ and then ./PretendParse …
Right now this does not work, even though the target app is there and has the right permissions.[/quote]
You can’t do this. Any path that begins with / is assumed to be at the root of the server, but that’s not where your files live, nor do you have permission to access anything up there.
I suspect the reason you’re getting errors is because your app is crashing with a NilObjectException.
Is there a way to get shell access for Xojo Cloud ? I have enabled SSH in the control panel, but the example looks to only communicate over port 5432 presumably to the databases supported by XC.
The given entry script is:-
ssh -L 5432:localhost:5432 dbadmin@www.integrated-care.com.au -N
What would be the port for StdIn (tty) or whatever the terminal on MacOS communicates via ??
If I can get a shell working then I can perhaps sort this out.
I am sorry to report that my shell experiments have not been fruitful.
I am unable to have a Xojo Cloud web app run a shell successfully. I cannot even get it to list the contents of the present working directory (i.e. neither pwd nor ls -la produce any output).
This does work in the debugger.
The shell is not going out of scope. When I send a command to it, the send checks .isRunning to ensure that the shell is extant; if not, then an advisory is posted to that effect. On that basis, my commands get to a live shell which persists long after the command would have been responded to.
I must ask if the shell is even meant to run under Xojo Cloud ? It seems that if you don’t allow SSH then a Xojo Cloud app which mimics the shell would also be “not allowed”.
I think I shall wrap this up into a small project and send off … although I am sure that this will only add to the workload at Xojo.
If there are any examples of a Xojo Cloud web app launching a console app on the same Xojo Cloud server … I’d be very grateful to see how it’s done.
Check the mode of that shell. You’ll want it set to Asynchronous for best results. [quote=297627:@Tony Barry]I must ask if the shell is even meant to run under Xojo Cloud ? It seems that if you don’t allow SSH then a Xojo Cloud app which mimics the shell would also be “not allowed”.[/quote]
I can tell you that the Shell object absolutely does work in Xojo Cloud. We’ve seen users call “top” and “ps” to get info about their processes.
I’d be very interested in seeing what it is that you’re doing because I’m not aware of any specific restrictions beyond the fact that your apps cannot access anything outside of the designated directories.
Many thanks for your continued interest. With some more work, I am able to get the environment variables (the shell command env) and alter the PATH to include the target folder. I can now launch my desired console app, and get an error code of 0 at completion.
The console app does not actually work, but I suspect this may be a firewall issue.
I will continue; and your thoughts are appreciated.