Yikes ! Where did example.com come from ?

Greetings all.

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:-

/home/sites/www.example.com/Shared_Documents/ProjectAlpha

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.

Regards,
Tony Barry
Sydney

It looks like the special folder is mapped differently than you were expecting in that environment and they did not get it exactly right…

Check your app id setting
Its the only place I can think of it might come from but I’m not certain

Hi James, Norman,

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.

usefulPath = "/Shared_Documents/TMW-Alpha/" cmd = "cd " + usefulPath + ret

Right now this does not work, even though the target app is there and has the right permissions.

My whole web app thinks it is somewhere in example.com … the SSL access logs say this about my effort to connect to my console app:-

##########
Timeout waiting for output from CGI script /home/sites/www.example.com/web/textme-supervisor/index.cgi, referer: https://www.integrated-care.com.au/textme-supervisor/
##########

This is not good.

Norman, The app identifier is set as com.workshop.textme-supervisor. No example.com in sight.

If there are any ideas from the Xojo crew I would be pleased to hear.

Regards,
Tony Barry
Sydney

What you see is absolutely correct. On Xojo Cloud, all user files are contained in a sub folder of

/home/sites/www.example.com

File that under “implementation detail”.

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.

Wow.

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 …

I am using the notes at the very bottom of the page :-
http://developer.xojo.com/xojo-cloud
“Using external apps and libraries”

Regards,
Tony Barry
Sydney

[quote=297615:@Tony Barry]I have stopped using SpecialFolder, with some misgivings to be sure, and attempted hard coding the path.

usefulPath = "/Shared_Documents/TMW-Alpha/"
cmd = "cd " + usefulPath + ret

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.

Regards,
Tony Barry
Sydney

We do not offer SSH terminal access on Xojo cloud, and there’s nothing to work out. Use

SpecialFolder.SharedDocuments.NativePath +  "TMW-Alpha"

Looking at the code you supplied:

cmd = "cd " + worker.ShellPath + ret // this is the yikes moment ... cmd = cmd + "./PretendParse" + ret

Instead of using a carriage return, use a ; as the delimiter. I think you’ll have better luck with that.

Also keep in mind that your parsing app will only stay running as long as the shell object stays in scope.

Thank you Greg. I will test.

Regards,
Tony Barry
Sydney

Hi Greg,

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.

Regards,
Tony Barry

OK. My stripped down project is … sort of working - at least the ls -la works.

I shall pursue the matter further, and report when I have something nice to say.

Heh.

Regards,
Tony Barry
Sydney

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.

Hi Greg,

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.

Regards,
Tony Barry
Sydney