C question
Chris F.A. Johnson
cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Thu Jul 20 19:17:15 UTC 2006
On Thu, 20 Jul 2006, Madison Kelly wrote:
> Hi all,
>
> As something of a follow-up to my last question, I need some C help (a
> language I am quite 'n00by' in :p ).
>
> What I want to do is, I think, simple. Take a set of command line options
> and use them when calling a perl script. From the ANSI C book I have gotten
> to the point where I can print the commands to STDOUT but I can't figure out
> how to put them into a variable. I know 'char' is for one byte, but don't
> know what type to use for a full string or how to concatenate the switches
> into the string.
>
> Here's what I've got so far (probably broken from playing with it):
>
> #include <stdio.h>
>
> #define REAL_PATH
> "/home/digimer/projects/mizu-bu/releases/mizu-bu/cgi-bin/exec-priv.pl"
> main(int argc, char *argv[])
main() always returns an int:
int main(int argc, char *argv[])
> {
> setuid(geteuid());
> setgid(getegid());
> var say;
> say="Hello";
char *say = "hello"; /* pointer to char; string cannot be modified */
char say[] = "hello"; /* array; string can be modified: */
say[2] = x; /* change 3rd char of the string */
>
> int i;
> for (i=1; i<argc; i++ )
> {
> printf("%s%s", argv[i], (i < argc-1) ? " " : "");
> }
> printf("\n");
> printf("%s", say);
> /* execv(REAL_PATH, av);*/
return 0;
> }
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list