From: linux-c-programming-owner@vger.kernel.org
To: linux-c-programming@vger.kernel.org
Subject: Re: script in c
Date: Sun, 7 Nov 2004 22:50:24 -0800 (PST) [thread overview]
Message-ID: <20041108065024.35087.qmail@web14001.mail.yahoo.com> (raw)
--- 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
next reply other threads:[~2004-11-08 6:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-08 6:50 linux-c-programming-owner [this message]
2004-11-08 7:27 ` script in c 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041108065024.35087.qmail@web14001.mail.yahoo.com \
--to=linux-c-programming-owner@vger.kernel.org \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).