Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-01

Re: chdir problem? -- 2nd request

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabor DEAK JAHN

At 01/10/2001 06:30, you wrote:

Dear Jim,

Show quoted text 5 lines
anyfile.name and have it find the file, CD into the directory where the file is and then exit (leaving you at the DOS prompt, but in the directory of the file you were searching for). The go32 targets work just fine, but the Win32 targets leave you in the directory that the program was launched from and not the directory where the file was found.

And it will probably remain so, there is no way to change the current directory of another program without it consenting (CMD.EXE could have been made to accept, for instance, DDE messages asking it to change the directory). The closest what I could think of is to put the found directory name, prefixed with the command CD, to the clipboard and instruct the user in the last line of the program's output that in order to change to that directory they could select Paste from the system menu, then press Enter. Far from perfect, I agree, but...

Bye,
   Gábor

------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary.
E-mail: ,

Reply by email

Jeff Patterson
to Gabor DEAK JAHN

There is a program that claims that it can change the current directory under DOS/Unix/Win32 Console (Win9x/NT/2000), Win32 ZShell, Win32 Cygwin, and more. http://www.xs4all.nl/~waterlan/

C Source appears to be available, but I have not looked at this program at all yet.

Earlier message 35 lines
----- Original Message ----- From: "Gabor DEAK JAHN" To: Sent: Thursday, January 11, 2001 6:42 PM Subject: [fpc-pascal]Re: chdir problem? -- 2nd request At 01/10/2001 06:30, you wrote: Dear Jim, > anyfile.name and have it find the file, CD into the directory where the > file is and then exit (leaving you at the DOS prompt, but in the directory > of the file you were searching for). The go32 targets work just fine, but > the Win32 targets leave you in the directory that the program was launched > from and not the directory where the file was found. And it will probably remain so, there is no way to change the current directory of another program without it consenting (CMD.EXE could have been made to accept, for instance, DDE messages asking it to change the directory). The closest what I could think of is to put the found directory name, prefixed with the command CD, to the clipboard and instruct the user in the last line of the program's output that in order to change to that directory they could select Paste from the system menu, then press Enter. Far from perfect, I agree, but... Bye, Gábor ------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary. E-mail: ,

Reply by email

Unknown author
to Jeff Patterson
Jeff Patterson wrote 6 lines
There is a program that claims that it can change the current directory under DOS/Unix/Win32 Console (Win9x/NT/2000), Win32 ZShell, Win32 Cygwin, and more. http://www.xs4all.nl/~waterlan/ C Source appears to be available, but I have not looked at this program at all yet.

It works only with a trick.
On Dos, the program creates a batch file which is then executed by the calling batchfile,

In bash or any unix shell, it is done using a script function;

the reason this is so is exactly because there is _no way_ to set the working directory of another process programatically.

So this is no good.

Michael.

Reply by email

Arne Hanssen
to Gabor DEAK JAHN: And it will probably remain so, there is no way to change the current directory of…

Thus spoke Gabor DEAK JAHN ():

Show quoted text 13 lines
At 01/10/2001 06:30, you wrote: > anyfile.name and have it find the file, CD into the directory where the > file is and then exit (leaving you at the DOS prompt, but in the directory > of the file you were searching for). The go32 targets work just fine, but > the Win32 targets leave you in the directory that the program was launched > from and not the directory where the file was found. ....... The closest what I could think of is to put the found directory name, prefixed with the command CD, to the clipboard and instruct the user in the last line of the program's output that in order to change to that directory they could select Paste from the system menu, then press Enter. Far from perfect, I agree, but...

Hmmm.. if you make your program launch a new CMD.EXE just before it exits (after changing path) - that new "command promt" should point to the desired directory?!?

Vennlig hilsen / Best regards |\ ___,,--, _ Arne Hanssen, Senja, Norway /,`--'' \-,,__,'/ http://home.enitel.no/ahh |,4 ) )_ ) /~-----' http://home.c2i.net/bkgras -----'---^~(_/-_)--(_/_)-------

Reply by email

Kuba Ober
to Unknown author: It works only with a trick. On Dos, the program creates a batch file which is then…
Show quoted text 15 lines
> There is a program that claims that it can change the current directory > under DOS/Unix/Win32 Console (Win9x/NT/2000), Win32 ZShell, Win32 Cygwin, > and more. http://www.xs4all.nl/~waterlan/ > > C Source appears to be available, but I have not looked at this program > at all yet. It works only with a trick. On Dos, the program creates a batch file which is then executed by the calling batchfile, In bash or any unix shell, it is done using a script function; the reason this is so is exactly because there is _no way_ to set the working directory of another process programatically.

And for good reason this is so... because there's really no real need to change the CD of a process that already runs, and if you're fork'ing a new one, it inherits the CD anyway.

People still think DOS-way and expect multiprocessing systems to behave the same way...

Kuba

Reply by email