1. set PATH=%PATH%...

I'm building a build system for a java game I'm
writing and it is in it's early stages.  I'm having a
problem
with setting the PATH var...

The code generates a "set PATH=..." sequence to send
to the command prompt.  If I run the generated
sequence from the command line, the path becomes
correctly set.

Does anyone see what I'm doing wrong? 
<pre>

-- OS = windows xp
-- Euphoria Interpreter 2.5 for 32-bit DOS.
-- string_cat() appends sequence 1 with each char from

-- sequence 2, one at a time.

constant JAVAC = "C:\\Program
Files\\Java\\jdk1.5.0_05\\bin"

procedure build_all()
  object return_code
  sequence path, cmd
  path = "%PATH%;"
  path = string_cat(path, JAVAC)
  cmd = string_cat("set PATH=", path)
  puts (1,"\n\n")
  puts (1, "procedure build_all()\n")
  puts(1,cmd)
  return_code = system_exec(cmd, 2)
  if (return_code < 0) then
    puts(1, "\n!!! command failed\n\n")
  end if
  path = getenv("PATH")
  puts (1, "\n\n")
  puts (1, "final path\n")
  puts(1, path)
  --build_client()
  --build_server()
end procedure

----
-- output 
--
--

procedure build_all()
set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_05\bin
!!! command failed

final path
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\ATITEC~1\ATI
CON~1;c:\PROGRA~1\MI6841~1\90\Tools\binn\;C:\EUPHORIA\BIN;


</pre>



--
Ronald Weidner
http://www.techport80.com
PHP Software developer for hire.

new topic     » topic index » view message » categorize

2. Re: set PATH=%PATH%...

Ron Weidner wrote:
> 
> I'm building a build system for a java game I'm
> writing and it is in it's early stages.  I'm having a
> problem
> with setting the PATH var...
> 
> The code generates a "set PATH=..." sequence to send
> to the command prompt.  If I run the generated
> sequence from the command line, the path becomes
> correctly set.
> 
> Does anyone see what I'm doing wrong? 
> <pre>
> 
> -- OS = windows xp
> -- Euphoria Interpreter 2.5 for 32-bit DOS.
> -- string_cat() appends sequence 1 with each char from
> 
> -- sequence 2, one at a time.
> 
> constant JAVAC = "C:\\Program
> Files\\Java\\jdk1.5.0_05\\bin"
> 
> procedure build_all()
>   object return_code
>   sequence path, cmd
>   path = "%PATH%;"
>   path = string_cat(path, JAVAC)
>   cmd = string_cat("set PATH=", path)
>   puts (1,"\n\n")
>   puts (1, "procedure build_all()\n")
>   puts(1,cmd)
>   return_code = system_exec(cmd, 2)
>   if (return_code < 0) then
>     puts(1, "\n!!! command failed\n\n")
>   end if
>   path = getenv("PATH")
>   puts (1, "\n\n")
>   puts (1, "final path\n")
>   puts(1, path)
>   --build_client()
>   --build_server()
> end procedure
> 
> ----
> -- output 
> --
> --
> 
> procedure build_all()
> set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_05\bin
> !!! command failed
> 
> final path
>
> C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\ATITEC~1\ATI
> CON~1;c:\PROGRA~1\MI6841~1\90\Tools\binn\;C:\EUPHORIA\BIN;
> 
> 
> </pre>
> 
> 
> --
> Ronald Weidner
> <a href="http://www.techport80.com">http://www.techport80.com</a>
> PHP Software developer for hire.
> 
> 
> 		
> 
> 
Can you try 'system()' instead of 'system_exec()' ?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

3. Re: set PATH=%PATH%...

> 
> Can you try 'system()' instead of 'system_exec()' ?
> 

Thanks for your quick response. 

I just gave that a try.  That didn't work either. 
Should it have?  Has anyone been successful at setting
the PATH var at run time?




--
Ronald Weidner
http://www.techport80.com
PHP Software developer for hire.

new topic     » goto parent     » topic index » view message » categorize

4. Re: set PATH=%PATH%...

What I'm thinking is probably happening is that it's getting set correctly but
not saved. In Windows XP paths set with the SET command aren't saved when the
command prompt closes. What you need to do is go into the registry and change
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\Path
to the path you want. I had to do this in Perl for an installation script at my
job back before I switched to Euphoria.


The Euphoria Standard Library project :
    http://esl.sourceforge.net/
The Euphoria Standard Library mailing list :
    https://lists.sourceforge.net/lists/listinfo/esl-discussion

new topic     » goto parent     » topic index » view message » categorize

5. Re: set PATH=%PATH%...

Ron Weidner wrote:
> 
> 
> > Can you try 'system()' instead of 'system_exec()' ?
> > 
> 
> Thanks for your quick response. 
> 
> I just gave that a try.  That didn't work either. 
> Should it have?  Has anyone been successful at setting
> the PATH var at run time?
> 
> 
> --
> Ronald Weidner
> <a href="http://www.techport80.com">http://www.techport80.com</a>
> PHP Software developer for hire.
> 
> 
> 	
> 		
> 
> 

Hi again Ron,

I mentioned 'system()' instead of 'system_exec()' because the latter
does not run built in dos commands, only executable files like "my.exe" .
system() is made for also running built in dos commands, but i have
a feeling when it returns the path goes back to whatever it was
before the call.

You can try using a .bat file if you like.  You'll have to write
the commands to a .bat file and then run the bat file.  I guess
all of the commands would have to be in with the bat file or else
when that returns the path goes back to what it was before the call
too.
If that doesnt work, perhaps you can try writing to the registry
under the path variables (there might be more than one).
Sorry i cant be more specific...it's been a while since i used these
things.

Perhaps Rob would be willing to add a 'set_environment_var' function
call to the next release?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

6. Re: set PATH=%PATH%...

> What I'm thinking is probably happening is that it's getting set correctl=
y but not saved. In Windows XP paths set with the SET command aren't saved =
when the command prompt closes.

You are entirely correct. In fact, each application gets its own
private environment variables, so any call to "set PATH=" is lost when
your app exits. The same holds true for SetEnvironmentVariable() in
the Windows API, all vars are lost when your app exits. These local
environment variables are really only useful for passing info to other
apps that your app spawns.

> What you need to do is go into the registry and change HKEY_LOCAL_MACHINE=
\SYSTEM\ControlSet001\Control\Session Manager\Environment\Path to the path =
you want. I had to do this in Perl for an installation script at my job bac=
k before I switched to Euphoria.

You are partially correct here. The only real way to force environment
variables is to add them to the registry. Typical installation
utilities (INNO, NSIS) do this when they install an app, like
Euphoria. I'm sure someone could make a small library that forces
environment variables using registry calls.

The correct registry location for User environment variables is
"HKEY_CURRENT_USER\Environment"

The correct registry location for System environment variables is
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment"

Also, keep in mind that environment variables are inherited. If the
Windows shell spawns your app, and you change an environment variable
in the registry, any call you make to getenv() won't see the change.
You'll have to set the variable twice, once with
SetEnvironmentVariable() (locally) and once in the registry
(globally).

Hope this helps, good luck.

~Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: set PATH=%PATH%...

On Mon, 26 Sep 2005 10:17:16 -0700 (PDT), Ron W <xecronix at yahoo.com>
wrote:

>I'm having a problem with setting the PATH var...
<snip>
My recommendation is to write (by hand or under pgm control) a .bat
file along the lines of:
set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_05\bin
<command you want to run>

Once you get that working, then think about permanently updating the
registry & such (eg if it kicks off an unwanted console, etc).

Are you planning to always invoke this from an Eu program, or are you
just attempting to install some java program properly/fully?

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

8. Re: set PATH=%PATH%...

My answer is to use: GNU make, or ANT.  Both are free and already done.  
Why reinvent them?

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu