1. Path pitfalls....

I need to run a euphoria program on a remote network location:
"\\fp-ho1-pr\HO_share\Tier 3 Database\bin\run.exw"

When it is run, the current directory is not that the same as where the file is
stored, because it's being run by an Access macro.
How can I change the current directory?

I'm using win2k, but mapping network drives is not an option, because it needs
to be run by other people.

It won't work with absolute addressing either, because two of it's calls are to
PHP scripts, and they don't like being addressed that way; it comes up with a CMD
error.
The script used to work when only using relative addressing ( \bin,  ..\ ,etc),
and running via a double click... not possible any more.

Any help VERY appreciated.
=======================
Patrick Barnes
Information Systems Group
201 Elizabeth St, Sydney
Patrick.Barnes at tg.nsw.gov.au
Ext: 91-3583
Ph:(02) 9284-3583
Mob: 0410 751 044


***********************************************************************

"This electronic message and any attachments may contain privileged
and confidential information intended only for the use of the 
addressees named above.  If you are not the intended recipient of 
this email, please delete the message and any attachment and advise
the sender.  You are hereby notified that any use, dissemination, 
distribution, reproduction of this email is prohibited.

If you have received the email in error, please notify TransGrid 
immediately.  Any views expressed in this email are those of the 
individual sender except where the sender expressly and with 
authority states them to be the views of TransGrid.  TransGrid uses
virus scanning software but excludes any liability for viruses
contained in any attachment.

Please note the email address for TransGrid personnel is now
firstname.lastname at transgrid.com.au"

***********************************************************************

new topic     » topic index » view message » categorize

2. Re: Path pitfalls....

Patrick,
I did some quick research and discovered that even though the API docs say 
you need a parent window, you can get by with out one for shellExecute. So 
if you'd like to do a small mod on the win32lib.ew file....

Find the shellExecute routine and change the lines ...

       warnErr("shellExecute requires a WinMain()")
       return 0

to ...
     hWnd = 0

And this should then be able to be used without a Main Window.

As another idea, you might like to get the current directory and prepend it 
to the file name before you try to execute it.


On Tue, 26 Nov 2002 08:36:51 +1100, <Patrick.Barnes at transgrid.com.au> wrote:

>
> Hmmm, I tried that.
>
> It doesn't want to run system() after I've changed the directory.
>
> On this line:
> system("php.exe Cat.php > export.html", 0)
>
> It puts out to screen this error message:
> CMD.EXE was started with '\\fp-ho1-pr\HO_Share\Tier 3 Database' as the 
> current directory path. UNC paths are not supported. Defaulting to 
> windows directory.
>
> What's the win32 equivalent for system?
>
> I tried using shellExecute("open", "bin\\php.exe bin\\Cat.php > 
> bin\\export.html", SW_SHOWNORMAL)
>
> but apparently it won't work without a winMain call. I don't want one, 
> this is a script, not an application.
>
> =======================
> Patrick Barnes
> Information Systems Group
> 201 Elizabeth St, Sydney
> Patrick.Barnes at tg.nsw.gov.au
> Ext: 91-3583
> Ph:(02) 9284-3583
> Mob: 0410 751 044
>
>
> -----Original Message-----
> From: Don Phillips [mailto:EuNexus at yahoo.com]
> Sent: Monday, 25 November 2002 16:42
> To: EUforum
> Subject: RE: Path pitfalls....
>
>
>> When it is run, the current directory is not that the same as where the file 
>> is stored, because it's being run by an Access macro.
>> How can I change the current directory?
>>
>> I'm using win2k, but mapping network drives is not an option, because it
>> needs
>> to be run by other people.
>>
>> It won't work with absolute addressing either, because two of it's calls are 
>> to PHP scripts, and they don't like being addressed that way; it comes 
>> up with a CMD error. The script used to work when only using relative 
>> addressing ( \bin,  ..\ ,etc), and running via a double click... not 
>> possible any more.
>>
>> Any help VERY appreciated.
>> =======================
>> Patrick Barnes
>> Information Systems Group
>> 201 Elizabeth St, Sydney
>> Patrick.Barnes at tg.nsw.gov.au
>> Ext: 91-3583
>> Ph:(02) 9284-3583
>> Mob: 0410 751 044
>
> This might work for you.  At least I think it should.  I have not tested this 
> personally.  In kernel32 dll is an API named SetCurrentDirectory.  It 
> takes a pointer to a path and changes the current directory for the current 
> process.
>
> Declaration:
> BOOL SetCurrentDirectory(
> LPCTSTR lpPathName // address of name of new current directory );
>
> include Win32Lib.ew
>
> ==========
> constant
> SetCurrentDirectory = registerw32Procedure(
> kernel32, "SetCurrentDirectoryA", {C_POINTER} )
>
> atom str
> str = allocate_string("\\\\fp-ho1-pr\\HO_share\\Tier 3 Database\\bin\\")
> w32Proc( SetCurrentDirectory, {str} )
> free( str )
> ==========
>
> Don
>
>
> ***********************************************************************
>
> "This electronic message and any attachments may contain privileged
> and confidential information intended only for the use of the addressees 
> named above.  If you are not the intended recipient of this email, please 
> delete the message and any attachment and advise
> the sender.  You are hereby notified that any use, dissemination,
> distribution,
> reproduction of this email is prohibited.
>
> If you have received the email in error, please notify TransGrid immediately. 
<snip>

>
>
>


-- 

cheers,
Derek Parnell

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

3. Re: Path pitfalls....

Try using shellExecuteEx instead...

shellExecuteEx( object verb, sequence file, object parms,
                 object defdir, atom style, atom struct)

shellExecute("open", "bin\\php.exe > bin\\export1.html", "bin\\Cat.php", 0, 
SW_SHOWNORMAL, 0)

Or maybe its the stdout redirection causing it.

On Tue, 26 Nov 2002 10:02:54 +1100, <Patrick.Barnes at transgrid.com.au> wrote:

>
> Damn, and I thought I'd figured it out, too.
>
> I got rid of all my system calls, and used shellExecute, but it didn't 
> quite work. No doubt I'm making a mistake somewhere.
>
> This is my code for one php file.
> -----------------------------------------------------------------
> --run the php script Cat, and output the results into export.html
> shellExecute("open", "bin\\php.exe bin\\Cat.php > bin\\export1.html", 
> SW_SHOWNORMAL)
>
> --open export.html as read, and the other two files as write.
> s = open("BIN\\export1.html","r")
> d1 = open("Tier 3 Apps by Category.html","w")
> d2 = open("Tier_3_Apps_by_Category.asp","w")
>
> --strip out the top two lines.
> line = gets(s)
> line = gets(s)
>
> --Copy the rest across to the destination files
> --read a line in.
> line = gets(s)
> while sequence(line) do --while the source file does not end...
> 	puts(d1, line) --output that line to d1
> 	puts(d2, line) --and d2
> 	line = gets(s) --and get a new line
> end while
>
> --close those files
> close(s)
> close(d1)
> close(d2)
> -------------------------------------------------------------------
> The other half of the program is almost identical.
> I thought it was working fine, but it turns out that the shellExecute 
> command doesn't do anything. What am I doing wrong?
> =======================
> Patrick Barnes
> Information Systems Group
> 201 Elizabeth St, Sydney
> Patrick.Barnes at tg.nsw.gov.au
> Ext: 91-3583
> Ph:(02) 9284-3583
> Mob: 0410 751 044
>
> -----Original Message-----
> From: Derek Parnell [mailto:ddparnell at bigpond.com]
> Sent: Tuesday, 26 November 2002 09:07
> To: EUforum
> Subject: Re: Path pitfalls....
>
>
> Patrick,
> I did some quick research and discovered that even though the API docs 
> say you need a parent window, you can get by with out one for 
> shellExecute. So if you'd like to do a small mod on the win32lib.ew 
> file....
>
> Find the shellExecute routine and change the lines ...
>
> warnErr("shellExecute requires a WinMain()")
> return 0
>
> to ...
> hWnd = 0
>
> And this should then be able to be used without a Main Window.
>
> As another idea, you might like to get the current directory and prepend 
> it to the file name before you try to execute it.
>
>
> On Tue, 26 Nov 2002 08:36:51 +1100, <Patrick.Barnes at transgrid.com.au> 
> wrote:
>
>>
>> Hmmm, I tried that.
>>
>> It doesn't want to run system() after I've changed the directory.
>>
>> On this line:
>> system("php.exe Cat.php > export.html", 0)
>>
>> It puts out to screen this error message:
>> CMD.EXE was started with '\\fp-ho1-pr\HO_Share\Tier 3 Database' as the
>> current
>> directory path. UNC paths are not supported. Defaulting to windows 
>> directory.
>>
>> What's the win32 equivalent for system?
>>
>> I tried using shellExecute("open", "bin\\php.exe bin\\Cat.php >
>> bin\\export.html",
>> SW_SHOWNORMAL)
>>
>> but apparently it won't work without a winMain call. I don't want one, this 
>> is a script, not an application.
>>
>> =======================
>> Patrick Barnes
<snip>



-- 

cheers,
Derek Parnell

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

4. Re: Path pitfalls....

Why are you forced to do this in a Windows environment? Can't you do it in 
DOS?

You could write the Eu program as a DOS program and wrap it in a .BAT file.

I suppose I'm not sure about how the whole thing gets kicked off.


On Tue, 26 Nov 2002 11:01:29 +1100, <Patrick.Barnes at transgrid.com.au> wrote:

>
> No dice, it IS the "> bin\\export1.html" that's the problem.
>
> Also, does the program halt until the shellExecute is finished? If it 
> doesn't, then that is going to cause problems too.
>
> Qs:
> ---
>
> 1. How to redirect stdout in the windows environment?
>
> 2. How to make the eu program wait until php.exe is finished?
>
>
> ==============================================
> _______<-------------------\__
> /  _____<--------------------__|===
> | |_    <-------------------/
> \__| Patrick Barnes
>
>
> -----Original Message-----
> From: Derek Parnell [mailto:ddparnell at bigpond.com]
> Sent: Tuesday, 26 November 2002 10:51
> To: EUforum
> Subject: Re: Path pitfalls....
>
>
> Try using shellExecuteEx instead...
>
> shellExecuteEx( object verb, sequence file, object parms,
> object defdir, atom style, atom struct)
>
> shellExecute("open", "bin\\php.exe > bin\\export1.html", "bin\\Cat.php", 
> 0, SW_SHOWNORMAL, 0)
>
> Or maybe its the stdout redirection causing it.
>
> On Tue, 26 Nov 2002 10:02:54 +1100, <Patrick.Barnes at transgrid.com.au> 
> wrote:
>
>>
>> Damn, and I thought I'd figured it out, too.
>>
>> I got rid of all my system calls, and used shellExecute, but it didn't quite 
>> work. No doubt I'm making a mistake somewhere.
>>
>> This is my code for one php file.
>> -----------------------------------------------------------------
>> --run the php script Cat, and output the results into export.html
>> shellExecute("open", "bin\\php.exe bin\\Cat.php > bin\\export1.html",
>> SW_SHOWNORMAL)
>>
>> --open export.html as read, and the other two files as write.
>> s = open("BIN\\export1.html","r")
>> d1 = open("Tier 3 Apps by Category.html","w")
>> d2 = open("Tier_3_Apps_by_Category.asp","w")
>>
>> --strip out the top two lines.
>> line = gets(s)
>> line = gets(s)
>>
>> --Copy the rest across to the destination files
>> --read a line in.
>> line = gets(s)
>> while sequence(line) do --while the source file does not end...
>> 	puts(d1, line) --output that line to d1
>> 	puts(d2, line) --and d2
>> 	line = gets(s) --and get a new line
>> end while
>>
>> --close those files
>> close(s)
>> close(d1)
>> close(d2)
>> -------------------------------------------------------------------
>> The other half of the program is almost identical.
>> I thought it was working fine, but it turns out that the shellExecute command
>>
>> doesn't do anything. What am I doing wrong?
>> =======================
>> Patrick Barnes
>> Information Systems Group
>> 201 Elizabeth St, Sydney
>> Patrick.Barnes at tg.nsw.gov.au
>> Ext: 91-3583
>> Ph:(02) 9284-3583
>> Mob: 0410 751 044
>>
>> -----Original Message-----
>> From: Derek Parnell [mailto:ddparnell at bigpond.com]
>> Sent: Tuesday, 26 November 2002 09:07
>> To: EUforum
>> Subject: Re: Path pitfalls....
>>
>>
>> Patrick,
>> I did some quick research and discovered that even though the API docs say 
>> you need a parent window, you can get by with out one for shellExecute. 
>> So if you'd like to do a small mod on the win32lib.ew file....
>>
<snip>



-- 

cheers,
Derek Parnell

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

5. Re: Path pitfalls....

Patrick Barnes writes:
> 1. How to redirect stdout in the windows environment?

With some versions of Windows, I think you can
redirect stdout from exw.exe, but with others 
(such as XP), you will have to download
a little utility called setsubsys from the Archive.
http://www.rapideuphoria.com/setsubsys.zip

Make a copy of exw.exe, and then run:
     setsubsys exw.exe /c

to convert exw.exe to a console application.
You can then redirect stdout. e.g. on the command-line:
     exw myprog.exw > myoutput

Keep your original exw.exe in euphoria\bin 
for GUI apps.

I'm not sure exactly what you are trying to do,
but that might help with the stdout part of it.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu