News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
murgaLua CGI %ENV
Author Message
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #1
RE: murgaLua CGI %ENV

I'm not sure if this would help or not. This is a VB script I wrote but do not use. It uses QTWeb, Mongoose and murgaLua. I had the QTWeb home page set to the lua script that I wanted to run. It gave the functionality that I was looking for, but my wife wanted to use a Mac and I didn't want to re-write it. My goal would be to have this functionality all into one lua file along with the lua application that runs in the web browser.

Code:
Set WshShell = CreateObject("WScript.Shell")
'WScript.Echo WshShell.CurrentDirectory

'Find where this script is located.
Dim here
here = WshShell.CurrentDirectory

'Define where mongoose is.
Dim mongoose
mongoose = here & "\mongoose\mongoose"

'Define where the mongoose configuration file is.
Dim mongooseConf
mongooseConf = here & "\mongoose\mongoose.conf"

'Define the cgi_interpreter for the mongoose configuration file.
Dim cgi_interpreter
cgi_interpreter = "cgi_interpreter      " & here & "\lua\murgaLua"

'Define the cgi_extensions for the mongoose configuration file.
Dim cgi_extensions
cgi_extensions = "cgi_extensions    .lua"

'Define the path minus the windows directory.
Dim up
up = split(here,"windows")

Dim up1    
up1 = up(0)

'Define the document_root for the mongoose configuration file.
Dim document_root
document_root = "document_root      " + up1 + "views"

'Define the access_control_list for the mongoose configuration file.
Dim access_control_list
access_control_list = "access_control_list      -0.0.0.0/0,+127.0.0.1"

'Define QtWeb.
Dim QtWeb
QtWeb = here & "\qtweb\QtWeb.exe"

'See what programs are running.
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")

'Loop though the list and see if mongoose is there.
For Each objProcess in colProcessList

'If mongoose is running mark it as true.
If objProcess.name = "MONGOOSE.EXE" then
    mongooseFound = True
    
    'This is in case mongoose.exe is in lowercase.
    ElseIF objProcess.name = "mongoose.exe" then
    mongooseFound = True
End if
Next
    
'If mongoose is running.
If mongooseFound = True then
        
'Let the user know that mongoose is already running.    
    'Msgbox("Mongoose is already running.")
        
    'Start QtWeb.
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & QtWeb & Chr(34), 0
    Set WshShell = Nothing
    
    'If mongoose is not already running.
    Else

    'Write the mongoose.conf file.
    Dim filesys, filetxt, getname, path
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set filetxt = filesys.CreateTextFile(mongooseConf, True)
    path = filesys.GetAbsolutePathName(mongooseConf)
    getname = filesys.GetFileName(path)
    filetxt.WriteLine(cgi_interpreter)
    filetxt.WriteLine(cgi_extensions)
    filetxt.WriteLine(document_root)
    filetxt.WriteLine(access_control_list)
    filetxt.Close

    'If the mongoose.conf file was created.
    If filesys.FileExists(path) Then
        'WScript.Echo ("Your file, '" & getname & "', has been created.")
  
        'Start mongoose
        Set WshShell = CreateObject("WScript.Shell")
        WshShell.Run chr(34) & mongoose & Chr(34), 0
        Set WshShell = Nothing
    End If  

'See what programs are running now.
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
    
'Loop though the list again and see if mongoose is there.
For Each objProcess in colProcessList

' Unhide this to see a list of each process.
'Msgbox(objProcess.name)

'If mongoose is running mark it as true.
If objProcess.name = "MONGOOSE.EXE" then
    mongooseFound1 = True
    
    'This is in case mongoose.exe is in lowercase.
    ElseIF objProcess.name = "mongoose.exe" then
    mongooseFound1 = True
    
End if
Next    
    
'If mongoose is running.
If mongooseFound1 = True then
        
    'Let the user know that mongoose is running.    
    'Msgbox("Mongoose is now running.")
        
    'Start QtWeb.
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & QtWeb & Chr(34), 0
    Set WshShell = Nothing

    'Run this check as long as mongoose or QtWeb is running.
    While 0 = 0
    
    'Define mongooseFound2 and set it as false.    
    mongooseFound2 = False
    
    'Define QtWebFound and set it as false.
    QtWebFound = False
    
    'Set a 2 second delay between checks.
    Set WshShell = CreateObject("WScript.Shell")
    wscript.sleep 2000
    
    'See what programs are running now.
    Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
    
    'Loop though the list and see what is there.
    For Each objProcess in colProcessList

    'If mongoose is running mark it as true.
    If objProcess.name = "MONGOOSE.EXE" then
    mongooseFound2 = True
    
        'This is in case mongoose.exe is in lowercase.
        ElseIF objProcess.name = "mongoose.exe" then
        mongooseFound2 = True
    
        'If QtWeb is running mark it as true.
        ElseIf objProcess.name = "QtWeb.exe" Then    
        
        QtWebFound = True
        
    End If
    Next    
    
    'If mongoose was killed, then kill QtWeb.
    If mongooseFound2 = False Then
    
        'Let the user know that this app is about to stop.
        Msgbox("Stopping Mongoose will kill this application!")
    
        'Open up a shell and kill QtWeb.
        WshShell.Run ("C:\Windows\system32\cmd.exe")
        ' I added sleep  to fix a problem
        wscript.sleep 50
        WshShell.sendkeys "taskkill /IM QtWeb.exe"
        wscript.sleep 50
        WshShell.SendKeys "{ENTER}"
    
        'Now kill the shell.
        wscript.sleep 50
        WshShell.sendkeys "taskkill /IM cmd.exe"
        wscript.sleep 50
        WshShell.SendKeys "{ENTER}"
    
        'Exit from the VB Script.
        WScript.Quit [exitcode]
    
        'If mongoose is running but QtWeb has been killed, stop mongoose.
    ElseIf QtWebFound = False Then
    
        'Msgbox("QtWeb has been Stoped!")
        
        'Open up a shell and kill mongoose.
        WshShell.Run ("C:\Windows\system32\cmd.exe")
        ' I Add sleep  to fix the problem :d
        wscript.sleep 50
        WshShell.sendkeys "taskkill /F /IM mongoose.exe"
        wscript.sleep 50
        WshShell.SendKeys "{ENTER}"
        wscript.sleep 50
        WshShell.sendkeys "taskkill /F /IM MONGOOSE.EXE"
        wscript.sleep 50
        WshShell.SendKeys "{ENTER}"
        
        'Now kill the sell.
        wscript.sleep 50
        WshShell.sendkeys "taskkill /IM cmd.exe"
        wscript.sleep 50
        WshShell.SendKeys "{ENTER}"
    
        'Exit from the VB Script.
        WScript.Quit [exitcode]
    
    End If

    Set WshShell = Nothing

    Wend
        
    'If mongoose did not start.
Else    
    
    Msgbox("Could not start Mongoose.")

    'End if mongoose is running (second check).     
End If    
    
'End if mongoose is running (first check).
End If

This post was last modified: 06-03-2012 05:16 AM by dvw86.

06-03-2012 05:13 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
murgaLua CGI %ENV - dvw86 - 03-23-2008, 06:42 AM
RE: murgaLua CGI %ENV - Juergen - 03-23-2008, 08:30 AM
RE: murgaLua CGI %ENV - dvw86 - 03-23-2008, 09:25 AM
RE: murgaLua CGI %ENV - Juergen - 03-23-2008, 09:48 AM
RE: murgaLua CGI %ENV - dvw86 - 03-23-2008, 10:40 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-23-2008, 08:17 PM
RE: murgaLua CGI %ENV - dvw86 - 03-24-2008, 03:39 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-24-2008, 04:04 AM
RE: murgaLua CGI %ENV - dvw86 - 03-24-2008, 06:29 AM
RE: murgaLua CGI %ENV - asafp - 03-24-2008, 06:55 AM
RE: murgaLua CGI %ENV - Juergen - 03-24-2008, 06:57 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-24-2008, 07:11 AM
RE: murgaLua CGI %ENV - Juergen - 03-25-2008, 05:55 AM
RE: murgaLua CGI %ENV - mikshaw - 04-12-2008, 12:51 PM
RE: murgaLua CGI %ENV - JohnMurga - 04-14-2008, 03:36 AM
RE: murgaLua CGI %ENV - Juergen - 04-15-2008, 01:30 AM
RE: murgaLua CGI %ENV - JohnMurga - 04-15-2008, 07:28 AM
RE: murgaLua CGI %ENV - dvw86 - 05-20-2012, 02:45 AM
RE: murgaLua CGI %ENV - JohnMurga - 05-28-2012, 04:51 AM
RE: murgaLua CGI %ENV - jpjacobs - 05-28-2012, 07:35 AM
RE: murgaLua CGI %ENV - dvw86 - 05-29-2012, 01:55 AM
RE: murgaLua CGI %ENV - JohnMurga - 05-30-2012, 08:52 PM
RE: murgaLua CGI %ENV - dvw86 - 06-02-2012, 12:27 PM
RE: murgaLua CGI %ENV - dvw86 - 06-02-2012, 12:50 PM
RE: murgaLua CGI %ENV - JohnMurga - 06-02-2012, 04:46 PM
RE: murgaLua CGI %ENV - dvw86 - 06-03-2012, 04:48 AM
RE: murgaLua CGI %ENV - dvw86 - 06-03-2012 05:13 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: