Triggering files using C

CA50

Well-Known Member
Adept
Dec 26, 2009
3,385
65
87
GraveYard
rock_ya_baby said:
Its not needed that they be in same dir. Those executables are in the System PATH. You can be in any dir and run those commands.
Its not working, can you give the code.:hap2:
thanks

kekerode said:
you tried exec() and spawn() functions for change?
how about a demo??:huh:
 

shantanugoel

Active Member
Adept
Dec 31, 2008
304
8
32
tech.shantanugoel.com
I think you have got enough leads by now but may I ask, what is it exactly that you want to achieve? I mean I get it that you want to open certain files through your program but what is the end goal?
 

CA50

Well-Known Member
Adept
Dec 26, 2009
3,385
65
87
GraveYard
@shantanugoel
I think you have got enough leads by now but may I ask, what is it exactly that you want to achieve? I mean I get it that you want to open certain files through your program but what is the end goal?
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C
 

viridian

New Member
Disciple
Jun 26, 2008
231
16
0
11
ritesh.posterous.com
CA50 said:
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C
If you're planning to run it on a Windows platform, have you considered using wscript? Or I suppose Powershell could pull this off quite easily too.
 

viridian

New Member
Disciple
Jun 26, 2008
231
16
0
11
ritesh.posterous.com
  • Like
Reactions: 1 person

blufox

Well-Known Member
Adept
Jun 2, 2009
360
70
67
Mountain View, CA
pr0ing said:
care to explain why the solution provided earlier is "not possible in C". I am open to learning new things.

or did you misinterpret the OP's question?
C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,
 

kekerode

Active Member
Adept
Jul 29, 2009
568
7
32
Bangalore
CA50 said:
thats a good question!!
Before C i was using batch file for such works, but now i feel that batch file are not good, there codes and be read and modified so i want to achieve that through C
Lets C
I forgot one thing ... exec() should not work because if u call notepad program from DOS C parent program with exec() (or other variant) then will try to execute notepad in DOS env ... which is not going to happen

Here Windows Scripting or Powershell scripting can help u much better

Apart from this ... there are several tools available which can convert these scripts to EXE files so your code will remain hidden

blufox said:
C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,
Yes ... C don't understand files, drivers etc ... that's why there r library which can be integrated which can do things for us

besides ... except you .c code file nothing is portable ... every executable is OS dependent

reason behind suggesting exec(), system() routines is very simple ... OS/system is going to handle execution ... not the calling C program
 

shantanugoel

Active Member
Adept
Dec 31, 2008
304
8
32
tech.shantanugoel.com
blufox said:
C does not understand your files, your driver, your mouse or any other thing.
It was specifically designed to be as portable as possible.
Adding additional work of meddling with standard C is not provided as part of standard itself.

What you people are suggesting him are system/OS specific routines which is not standard C.

It is very imp that there is a difference between C and system specific functions like exec(), execve() etc.

Cu,
You are correct, but yet incorrect. Yes, C standard (and C language) does not have any inbuilt routines to do this. But to say that this is not possible in C is blasphemy. For all that matters, first, the functions given are part of stdlib/libc with most compilers. Second, even if the functions aren't there, one can always write the code in C to achieve the functionality. So, "not possible in C" is a semi-ignorant answer, and we know that little knowledge is a dangerous thing ;)
 

blufox

Well-Known Member
Adept
Jun 2, 2009
360
70
67
Mountain View, CA
routine you are again talking about are OS specific and No they do not constiture standard C.

There is a reason books are named "System Programming in C". System here gets OS specific and thus the catch.

And no I do not take offense to any of your statements but if you think I am wrong, feel free to correct me.