SOLVED! - Shell not working under LiveCode Server & IIS 5.1

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

SOLVED! - Shell not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Fri Aug 12, 2011 1:03 am

I've got the LiveCode Scripting Server (not on-rev) running under my IIS 5.1 Server.

<?lc LiveCode scripts are working as expected. ?>

However I'm trying to execute the Shell Command but it just won't execute as far as I can tell.

Any help would be greatly appreciated.

Code: Select all

<html>
<br>  Test 10  <br><br>
<?lc 

   set the errorMode to "inline"   -- verbose error reporting in LiveCode server
   -- inline - Indicates that errors should be output to the browser.
   -- stderr - Specifies that the error should be written out to stderr.
   -- quiet - Indicates that nothing is output anywhere when an error occurs.
   -- debugger - For information only and indicates that the script is being run in 'remote debug' mode. This is only relevant to the on-rev engine.


	if there is a file "MyApp.exe" then
        	put "<br><br>MyApp.exe - file exists<br><br>"
	end if

	if there is a file "C:\MyApp.exe" then
	        put "<br><br>C:\MyApp.exe - file exists<br><br>"
	end if

   set the defaultFolder to "C:\"
   put "MyApp.exe MyUserID MyPW" into tCommand 
   -- set hideConsoleWindows to true
   put tCommand
   put "<br><br>"


   -- generates C:\myUID.xml

   -- PUT Shell(tCommand)  -- PUT Shell(tCommand) - DOES NOT WORK
   	                    -- PUT Shell - Places a value into a container.
                        --       but - since the MyApptake a few seconds to run
                        --       this command returns an immediate error:
                        --       Error Occured: Access to the path 'C:\MyUerID.xml' is denied.
                        --       So better to use the GET command  

   GET Shell(tCommand)  -- PUT - puts the results into the IT variable
   
   
   
   
   put "<br><br>***  Command Completed   ***<br><br>"
   
   -- Put the shortname of the target   -- test to display errors

?>
</html>

This works in my WindowsXP32bit standalone executable
but NOT with Start Using Stack (no controls just script in OpenStack):

Code: Select all

...
   set the defaultFolder to "C:\"
   put "MyApp.exe MyUserID MyPW" into tCommand 
   set hideConsoleWindows to true
   Get Shell(tCommand) 
...
Last edited by BarrySumpter on Tue Aug 16, 2011 10:15 pm, edited 5 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server

Post by BarrySumpter » Fri Aug 12, 2011 1:12 am

Also, watching this vid seems I should be able to run the shell command:
5. Integrating with desktop Revolution
http://www.screencast.com/users/Runtime ... 16f98c32be

The presenter has created an executable to shell to:

Code: Select all

<?rev   Put Shell("uptime")  ?>
But there is no further info of uptime.
Where is uptime placed on the server?
Why is there no file path?
Is uptime an actual executable?
What's the file extention for uptime?
Does the Shell command need a file path or a file extention under LiveCode Scripting Server?
Is uptime a livecode app?
How does uptime send info back to the server script?
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 264
Joined: Mon May 18, 2009 4:12 am

Re: Shell Command not working under LiveCode Server

Post by wsamples » Fri Aug 12, 2011 2:58 am

uptime is a Unix shell command. Example:

warren@suse:~> uptime
20:50pm up 7 days 19:43, 3 users, load average: 1.08, 1.31, 1.30
warren@suse:~>

The code should run the shell command and insert the result into the html in place of the code in a Unix environment.

http://www.computerhope.com/unix/uptime.htm

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Sat Aug 13, 2011 12:29 am

Yeah, OK.

put shell("dir") -- WORKS

dir is a DOS command

Perhaps Shell command in LiveCode Server is limited to OS commands?
Or perhaps console apps only ?

Anyone else been able to get the shell to .exe to work or not?
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by Mark » Sun Aug 14, 2011 12:06 am

Hi Barry,

Use the shell function for any syntax that could also be executed from the command line/console/terminal, as long as it doesn't need to be interactive. You can even run a LiveCode standalone from the command line, this you can start a LiveCode standalone from the shell function.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Sun Aug 14, 2011 5:04 am

OK,
MyApp.exe has a MyApp.dll it needs.

LiveCode Scripting server will NOT shell to MyApp.exe.
I don't know why.
Is there a special way to send parameters to MyApp.exe using the shell command?

MyApp. exe and MyApp.dll are C# and VB objects written in .net by someone else.
I have no control over MyApp.exe nor MyApp.dll.

Yes, LiveCode Scripting Server Shell command WILL execute other .exe apps without issue.
I don't know why is won't execute MyApp.exe.

I've tested LiveCode desktop running a VBScript that works on the desktop:

This is VBScript code

Code: Select all


Set Command = WScript.CreateObject("WScript.Shell")
cmd = "c:\MyApp.exe"
Command.Run (cmd) 

msgbox "hello - cscript to vbs - world!"

I'm researching now how to execute this VBScript using the LiveCode Scripting Server test scripts.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by SparkOut » Sun Aug 14, 2011 9:58 am

Will it (MyApp) work if you copy the dll to the same folder as the exe? What about if you move both the exe and dll into a folder that you know have writeable permissions (in the context of the IIS user account)?

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Sun Aug 14, 2011 10:17 am

Brains getting a bit foggy now with too much research and trial and error.

I could swear under LiveCode Scripting Server
MyApp.exe would only run with the .dll under a bin sub-folder.
Trying now to reconstruct the environment.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by Mark » Sun Aug 14, 2011 11:22 am

BarrySumpter,

Do you have any documentation for that C# app? What does it say about being run from the command line? Does it have an interface? Was it made to be run from the command line? Does the documentation say it needs parameters?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Sun Aug 14, 2011 11:49 am

Thanks for the continued assistance.

No doco at all.

Just stumbled upon a .aspx using C#.net using MyApp.dll .
Trying to convert the c# to vb.net so I can read it better.
Might have gotten lucky here.

I wonder, does LiveCode Scripting Server use externals like MyApp.dll ?
i.e. One thats already been created.

Yep, I can get it to work via vb.net in .aspx page.
Now I can fire it via my Android web brower as well.

Just wondering about converting to LiveCode Scripting Server external ...

Code: Select all

<%@ Page ContentType="text/xml" EnableSessionState="false" %>
<%@ Import Namespace="MyApp" %>                         ----------   MyApp.dll
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>


<script language="VB" runat="server">

Private Sub Page_Load(sender As Object, e As EventArgs)
...
MyAppObject = New MyApp.Create()
MyAppObject = New MyApp.LoadUser("Barry G. Sumpter")
...
Response.write (MyAppObject.userid)
Response.write (MyAppObject.phone)
...

All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Shell Command not working under LiveCode Server & IIS 5.1

Post by BarrySumpter » Tue Aug 16, 2011 4:26 am

Farkel!

Got it working now.

Doesn't matter if the physical virtual folder is under the iNetPub folder or not.

Trying to shell witn LiveCode Scripting Server on IIS 5.1
For MyApp.exe
1) Everything has to be with in one of the folder that IIS knows about.
( Althogh I could execute every other .exe I could find, MyApp.exe would NOT execute unless on an IIS folder.)

2) MyApp.exe uses a MyApp.dll
When MyApp.exe is on the wwwroot - MyApp.dll had to be in wwwroot
Or instead of wwwroot MyApp.exe and MyApp.dll had to be together in a IIS virtural folder.
(it would NOT execute properly if the MyApp.dll was in a sub-folder 'bin' or anywhere else in a sub folder)

3) Since MyApp.exe needed to write an xml (text) file to a folder
(usually where MyApp.exe is)
I had to set the defaultFolder in LiveCode to a folder IIS knows about
Both wwwroot and an IIS virtual folder worked properly.
If I tried "c:\" and receved a permissions error.

Code: Select all

...
set the defaultFolder to "M:\MyVirtual_IIS_CGIBinFolder\"
...

Code: Select all

<?lc

      Put "<br><br>Hello LiveCode Scripting Server World!<br><br>"

      set the defaultFolder to "M:\MyCGIBIN\"
      -- M:\MyCGIBIN\ contans both MyApp.exe and MyApp.dll
      -- M:\MyCGIBIN\ has been setup in IIS 5.1 as a Virtural Directory
      --     and has been given full access Read, Write, Dir Browsing, etc
      --     with Execute Pemissioins: Scripts and Executable
     --      with Appl Protection: Medium Pooled      
      --     with .lc file extension Mapped to LiveCode-Server.exe %s (I don't know what the %s is for)

      put "MyApp.exe UserID UserPW" into tCommand 
      
      set hideConsoleWindows to true
      
      Put Shell(tCommand) 


      Put "<br><br>Goodbye LiveCode Scripting Server World!<br><br>"

?>
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply