Pelles C forum

Pelles C => Bug reports => Topic started by: nsp on September 14, 2009, 05:15:17 PM

Title: trouble with system
Post by: nsp on September 14, 2009, 05:15:17 PM
with previous version of PellesC and other compiler (gcc, tinycc) the code :

system("notepad somefile.c");

launched notepad as expected.

with version 6.0.004 notepad is not launched a message :
"notepad is not an internal command..."
Title: Re: trouble with system
Post by: JohnF on September 14, 2009, 09:54:48 PM
It works with no problem here.

John
Title: Re: trouble with system
Post by: TimoVJL on September 15, 2009, 06:54:55 AM
Try to compile and run this:

system("set");

Then you find out that in the debugger PATH is limited:

Path=C:\Program Files\PellesC6\Bin
Title: Re: trouble with system
Post by: JohnF on September 15, 2009, 08:35:45 AM
Quote from: timovjl on September 15, 2009, 06:54:55 AM
Try to compile and run this:

system("set");

Then you find out that in the debugger PATH is limited:

Path=C:\Program Files\PellesC6\Bin


I don't understand what you are saying, could you explain a little more fully.

John
Title: Re: trouble with system
Post by: nicolas.sitbon on September 15, 2009, 10:18:43 AM
Pelles C 6.0 final 32 bits

#include <stdlib.h>

int main(void)
{
   system("notepad.exe somefile.c");
   return 0;
}


Quote'notepad.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Press any key to continue...

traduction for non french people  :P:
Quotenotepad is not an internal command...
Title: Re: trouble with system
Post by: TimoVJL on September 15, 2009, 01:01:47 PM
When you execute that program from POIDE it use that limited search PATH as i showed with that example with SET-command.
Outside POIDE you program should find that notepad.exe
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
system("notepad somefile.c");
//system("set");
printf("%s\n", getenv("PATH"));
return 0;
}

Compile that example and check that PATH enviroment variable
Title: Re: trouble with system
Post by: AlexN on September 15, 2009, 01:23:15 PM
Quote from: nicolas.sitbon on September 15, 2009, 10:18:43 AM
Pelles C 6.0 final 32 bits

#include <stdlib.h>

int main(void)
{
   system("notepad.exe somefile.c");
   return 0;
}


Quote'notepad.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Press any key to continue...

traduction for non french people  :P:
Quotenotepad is not an internal command...

When you start any program at POIDE from the debugger or the extra menu the environment variable PATH will be set to bin-directory of Pelles C. If you use the complete path to the program it works, if you use it outside of Pelles C it will also work.
Title: Re: trouble with system
Post by: JohnF on September 15, 2009, 01:28:54 PM
Quote from: timovjl on September 15, 2009, 01:01:47 PM
When you execute that program from POIDE it use that limited search PATH as i showed with that example with SET-command.
Outside POIDE you program should find that notepad.exe
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
system("notepad somefile.c");
//system("set");
printf("%s\n", getenv("PATH"));
return 0;
}

Compile that example and check that PATH enviroment variable


As I said before, no problems here. Notepad loads ok.

And all the paths of the PATH variable are printed too.

John

Title: Re: trouble with system
Post by: TimoVJL on September 15, 2009, 02:19:17 PM
Check from POIDE menus Tools->Options->Folders Executables that
your Windows\System32 folder is there.
Title: Re: trouble with system
Post by: nsp on September 16, 2009, 10:47:52 AM
Quote from: AlexN on September 15, 2009, 01:23:15 PM......

When you start any program at POIDE from the debugger or the extra menu the environment variable PATH will be set to bin-directory of Pelles C. If you use the complete path to the program it works, if you use it outside of Pelles C it will also work.
Thx for the hint, but this is an unattended behavior, why changing the context ?

Adding the executable path in front of standard path could be a good solution instead of completely replacing it !

debugging and execution from the menu should not differ from what i can do from command line !
Title: Re: trouble with system
Post by: TimoVJL on September 16, 2009, 11:32:15 AM
QuoteAdding the executable path in front of standard path could be a good solution instead of completely replacing it !

debugging and execution from the menu should not differ from what i can do from command line !

Setup copy current PATH-enviroment variable to there.
Default-button copy those values too and you can test it if you want.

PellesC programs and Tools use that path too.

It's nice feature that you can change that for debugging.