linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: script in c
@ 2004-11-08  6:50 linux-c-programming-owner
  2004-11-08  7:27 ` Glynn Clements
  0 siblings, 1 reply; 6+ messages in thread
From: linux-c-programming-owner @ 2004-11-08  6:50 UTC (permalink / raw)
  To: linux-c-programming

--- kaushal <kaushal@rocsys.com> wrote:

> Hello  all,

Hello,

>            Is there a way by which I can exec a
> shell script without
> using the "system()" call?
> Thanks in advance.

You can use exec*() family for this purpose.

man exec

Here is a little sample:

[mbaris@zion:/tmp/code_temp]$ cat exec.c
#include <unistd.h>
#include <string.h>
#include <errno.h>

int main(void)
{
  if (execl("/bin/sh", "-c", "./script.sh", NULL)==-1)
  {
    printf("ERROR: %s\n", strerror(errno));
  }

  return 0;
}


[mbaris@zion:/tmp/code_temp]$ cat script.sh
#!/bin/bash

echo "Fired!";
exit;

[mbaris@zion:/tmp/code_temp]$ gcc -o exec exec.c
[mbaris@zion:/tmp/code_temp]$ ./exec
Fired!
[mbaris@zion:/tmp/code_temp]$

>  
> cheers-
> kaushal.
> 


=====
M.Barýþ Demiray

DOS: n., A small annoying boot virus that causes random 
spontaneous system crashes, usually just before saving a massive project. Easily cured by UNIX.  See also MS-DOS, IBM-DOS, DR-DOS.


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: script in c
@ 2004-11-08  6:15 Honnavalli_Sreevathsa
  2004-11-08  6:32 ` Ron Michael Khu
  0 siblings, 1 reply; 6+ messages in thread
From: Honnavalli_Sreevathsa @ 2004-11-08  6:15 UTC (permalink / raw)
  To: kaushal, linux-c-programming

You can use popen() and pclose() calls


> -----Original Message-----
> From: linux-c-programming-owner@vger.kernel.org 
> [mailto:linux-c-programming-owner@vger.kernel.org] On Behalf 
> Of kaushal
> Sent: Monday, November 08, 2004 11:09 AM
> To: linux prg
> Subject: script in c
> 
> 
> Hello  all,
>            Is there a way by which I can exec a shell script 
> without using the "system()" call? Thanks in advance.
>  
> cheers-
> kaushal.
> 
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-c-programming" in the body of a message to 
> majordomo@vger.kernel.org More majordomo info at  
http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread
* script in c
@ 2004-11-08  5:39 kaushal
  0 siblings, 0 replies; 6+ messages in thread
From: kaushal @ 2004-11-08  5:39 UTC (permalink / raw)
  To: linux prg

Hello  all,
           Is there a way by which I can exec a shell script without
using the "system()" call?
Thanks in advance.
 
cheers-
kaushal.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-08  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-08  6:50 script in c linux-c-programming-owner
2004-11-08  7:27 ` Glynn Clements
  -- strict thread matches above, loose matches on Subject: below --
2004-11-08  6:15 Honnavalli_Sreevathsa
2004-11-08  6:32 ` Ron Michael Khu
2004-11-08  6:48   ` Jan-Benedict Glaw
2004-11-08  5:39 kaushal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).