starting java using process

Started by mostlywrong, January 16, 2009, 07:05:21 PM

Previous topic - Next topic

mostlywrong

looking at the problem i have with running the demo programs newlisp is not starting java with the process function.

I have been trying to get Java to start from newlisp for several days now and pretty much out of ideas.

I can pretty much run any none java program with any arguments that i want using process to start them, except for java.

On another note I can start the java guiserver and pass in a newlisp source file using python..



Would i get different results using the console rather than newLISP Edit? That's where i have been working from so far.





Looking in the Tips and tricks section i found this:
QuoteRun a Win32 shell and hide window

and after a little fumbling it works.

what is the difference  between process and the the win32 shell function?

Lutz

#1
Please try the following things from newLISP started in a command shell window (not the bottom part of the editor).



> !dir


The exclamation mark should be the first character and the word: dir should immediately follow it.



If this works try the following:



> (process "cmd /c dir")


and last:



> (exec "dir")


Tell me if these things work. If these things work, try the same in the bottom shell windows of the newLISP-GS editor. If it works or not, in either case tell me what happens.


Quotewhat is the difference between process and the the win32 shell function?


The win32 shell is a program running as a process. In the (process "cmd /c dir") example, newLISP starts the win32 shell as a new process and executes the "dir" command in it.

mostlywrong

#2
!dir

From cmd shell in the newlisp folder:

gives a dir listing of the "newlisp" folder.



From the lower pain of newLISP edit:

gives a dir listing of "C:Documents and Settingsfred" which is the root of my login folder for my windows settings.



----------------------

(process "cmd /c dir")

From cmd shell in the newlisp folder:

gives nil



From the lower pain of newLISP edit:

gives nil



----------------------

(exec "dir")

From cmd shell in the newlisp folder:

gives an "extended" dir listing of the "newlisp" folder



From the lower pain of newLISP edit:

gives a "extended" dir listing of "C:Documents and Settingsfred" which is the root of my login folder for my windows settings.


> (main-args)
("C:\newlisp\newlisp.exe" "-C" "-w" "C:\Documents and Settings\fred")
From the lower pain of newLISP edit

---------------------------------------------------------------

I think my problem might have something to do with the arg passing to the program being called.



I was able to start guiserver with win32shell and pass in the newlisp file and have them both start. I wasn't able to do that with process. win32shell has a arg for cmd args.



Thanks for the help. It looks interesting and simple enough for a beginner to learn.

xytroxon

#3
Quote from: "mostlywrong"
> (main-args)
("C:\newlisp\newlisp.exe" "-C" "-w" "C:\Documents and Settings\fred")



Is there a conflict with your newLISP not being installed in "C:Program Filesnewlisp"???



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

mostlywrong

#4
no. its the same problem. I moved new lisp folder to where you see it now and changed all the shortcuts and env settings tring to see if it was a "space in the path" problem.



thanks for asking though. bugging me to death.

Lutz

#5
It should work in custom-chosen install directories too, as long as NEWLISPDIR and the executable path point to the correct location.



But back to what we were doing:



The 'process' function should display a directory listing too, but doesn't.  Lets try the following in a cmd shell, to check if the shell program "cmd.exe" exists at all and is in the executable path with that name:


cmd /c dir

if this still works, lets see if the newLISP 'process' function works with some other known program:


> (process "notepad.exe")


This should pop up the Win32 notepad.exe editor. Try this in both the cmd shell and the the lower pane of newLISP edit.



Also what is this? C:Program FilesAltirisSoftware Virtualization Agent

mostlywrong

#6
from a cmd prompt ( just happens to be in newlisp dir)
cmd /c dirgave me a dir listing of the current dir.

changed to c: and repeated and gave me dir listing of current dir.



from newlisp:
(process "notepad.exe")returned nil. no notepad.


(process "c:/windows/system32/notepad.exe")works and opens a notepad.



path problems? I'm not sure. I had done some testing of the pate before trying to rule it out.



I know this is comparing apples to oranges but...

using python prompt: import subprocess, os, sys
subprocess.Popen('notepad.exe',shell=True)
works. notepad opens.



If it is a path problem I'm not see it. Maybe a frese set of eyes could see it.> (env)
(("ADMINTOOLS" "C:\Documents and Settings\fred\Start Menu\Programs\Administrative Tools")
 ("ALLUSERSPROFILE" "C:\Documents and Settings\All Users")
 ("APPDATA" "C:\Documents and Settings\fred\Application Data")
 ("CACHE" "C:\Documents and Settings\fred\Local Settings\Temporary Internet Files")
 ("CDBURNING" "C:\Documents and Settings\fred\Local Settings\Application Data\Microsoft\CD Burning")
 ("COMMONADMINTOOLS" "C:\Documents and Settings\All Users\Start Menu\Programs\Administrative Tools")
 ("COMMONAPPDATA" "C:\Documents and Settings\All Users\Application Data")
 ("COMMONDESKTOP" "C:\Documents and Settings\All Users\Desktop")
 ("COMMONDOCUMENTS" "C:\Documents and Settings\All Users\Documents")
 ("COMMONFAVORITES" "C:\Documents and Settings\All Users\Favorites")
 ("COMMONFILES" "C:\Program Files\Common Files")
 ("COMMONMUSIC" "C:\Documents and Settings\All Users\Documents\My Music")
 ("COMMONPICTURES" "C:\Documents and Settings\All Users\Documents\My Pictures")
 ("CommonProgramFiles" "C:\Program Files\Common Files")
 ("COMMONPROGRAMS" "C:\Documents and Settings\All Users\Start Menu\Programs")
 ("COMMONSTARTMENU" "C:\Documents and Settings\All Users\Start Menu")
 ("COMMONSTARTUP" "C:\Documents and Settings\All Users\Start Menu\Programs\Startup")
 ("COMMONTEMPLATES" "C:\Documents and Settings\All Users\Templates")
 ("COMMONVIDEO" "C:\Documents and Settings\All Users\Documents\My Videos")
 ("COMPUTERNAME" "USER")
 ("ComSpec" "C:\WINDOWS\system32\cmd.exe")
 ("COOKIES" "C:\Documents and Settings\fred\Cookies")
 ("DEFAULTUSERPROFILE" "C:\Documents and Settings\Default User")
 ("DESKTOP" "C:\Documents and Settings\fred\Desktop")
 ("FAVORITES" "C:\Documents and Settings\fred\Favorites")
 ("FONTS" "C:\WINDOWS\Fonts")
 ("FP_NO_HOST_CHECK" "NO")
 ("HISTORY" "C:\Documents and Settings\fred\Local Settings\History")
 ("HOMEDRIVE" "C:")
 ("HOMEPATH" "\Documents and Settings\fred")
 ("LOCALAPPDATA" "C:\Documents and Settings\fred\Local Settings\Application Data")
 ("LOCALSETTINGS" "C:\Documents and Settings\fred\Local Settings")
 ("LOGONSERVER" "\\USER")
 ("MEDIAPATH" "C:\WINDOWS\Media")
 ("MSSHAREDTOOLS" "C:\Program Files\Common Files\Microsoft Shared")
 ("MYMUSIC" "C:\Documents and Settings\fred\My Documents\My Music")
 ("MYPICTURES" "C:\Documents and Settings\fred\My Documents\My Pictures")
 ("MYVIDEO" "C:\Documents and Settings\fred\My Documents\My Videos")
 ("NETHOOD" "C:\Documents and Settings\fred\NetHood")
 ("NEWLISPDIR" "C:\newlisp")
 ("NUMBER_OF_PROCESSORS" "1")
 ("OS" "Windows_NT")
 ("Path" "PATH=C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\Program Files\UltraEdit-32;C:\Program
 Files\Altiris\Software Virtualization Agent\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program F
iles\ActiveState Komodo Edit 5\;C:\Program Files\Java\jre6\bin;C:\newlisp")
 ("PATHEXT" ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.jar")
 ("PERSONAL" "C:\Documents and Settings\fred\My Documents")
 ("PRINTHOOD" "C:\Documents and Settings\fred\PrintHood")
 ("PROCESSOR_ARCHITECTURE" "x86")
 ("PROCESSOR_IDENTIFIER" "x86 Family 15 Model 12 Stepping 0, AuthenticAMD")
 ("PROCESSOR_LEVEL" "15")
 ("PROCESSOR_REVISION" "0c00")
 ("PROFILESDIRECTORY" "C:\Documents and Settings")

 ("PROGRAMFILES" "C:\Program Files")
 ("PROGRAMS" "C:\Documents and Settings\fred\Start Menu\Programs")
 ("PROMPT" "$P$G")
 ("RECENT" "C:\Documents and Settings\fred\Recent")
 ("SENDTO" "C:\Documents and Settings\fred\SendTo")
 ("SESSIONNAME" "Console")
 ("STARTMENU" "C:\Documents and Settings\fred\Start Menu")
 ("STARTUP" "C:\Documents and Settings\fred\Start Menu\Programs\Startup")
 ("SystemDrive" "C:")
 ("SystemRoot" "C:\WINDOWS")
 ("TEMP" "C:\DOCUME~1\fred\LOCALS~1\Temp")
 ("TEMPLATES" "C:\Documents and Settings\fred\Templates")
 ("TMP" "C:\DOCUME~1\fred\LOCALS~1\Temp")
 ("USERDOMAIN" "USER")
 ("USERNAME" "fred")
 ("USERPROFILE" "C:\Documents and Settings\fred")
 ("windir" "C:\WINDOWS"))
>
Ok thats stright from the cmd prompt running newlisp with no editing.

DrDave

#7
From what I was able to extract form your earlier posts, you did not install newLISP to the default settings. So, perhaps when you were moving things around, not all your paths match where your target files reside. For example, on my installation using the default settings, I have

 ("NEWLISPDIR" "C:\Program Files/newlisp")

but you have

 ("NEWLISPDIR" "C:\newlisp")



The first thing that I would have done when encountering such a problem is simply uninstall and then reinstall using the default settings.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.

\"Getting Started with Erlang\"  version 5.6.2

mostlywrong

#8
sorry I wasn't clear before.



I installed to the default dir at first.



Then moved to the root folder.



I will delete and reinstall to the default folder.

Lutz

#9
lets continue with out experiments, in case you reinstalled, just check that NEWLIDPDIR and executable path are fine.



We have a problem with process not finding the path in (process "cmd /c dir"), Which is strange because the path environment variable seems to be fine. Same as on my XP-SP2 system, where both cmd and notepad are found using 'process'.



Lets try the following:


(process "c:\WINDOWS\system32\cmd.exe /c dir")



As you tried the same with notepad.exe it should work. If this works I will give you a modified guiserver.lsp. Where cmd.exe is called with its's full path

mostlywrong

#10
Quote(process "c:\WINDOWS\system32\cmd.exe /c dir")
works just fine.

Lutz

#11
Put guiserver.lsp line 750 back to the original content; this assumes that your .jar -> javaw.exe association is working.



Then change line 1813 from:


(process (string "cmd /c " server-path " " portIn))


to:


(process (string "c:\WINDOWS\system32\cmd.exe  /c " server-path " " portIn))


Now you should be able to do in a Win32 cmd shell:


newlisp c:newlispguiserverbuttom-demo.lsp

mostlywrong

#12
you got me Lutz. and it was painful. my eyes are not as good as they use to be. newlisp c:newlispguiserverbuttom-demo.lsp That m in buttoM killed me!  :)



Things seem t work as expected now. Thank you for your Patience.



What it different about my machine that the path to CMD does not work like others ?

Lutz

#13
QuoteWhat it different about my machine that the path to CMD does not work like others ?


no idea, and sorry for the 'm' in button; I am glad it works now ;-)

mostlywrong

#14
what is your path and maybe the (env) from newlisp.

programming is a hobby but PC troubles is like an itch.