1827856 Members
1546 Online
109969 Solutions
New Discussion

C script

 
System Dude_1
Frequent Advisor

C script

Dear Friend,

Could anybody help me on doing a C programming of below item:

1. I need to pass in parameter to the C and return in the result.

EXIT_VAL=`rsh -l oracle 192.100.100.100 /export/home/oracle/test.sh $1`
echo "$EXIT_VAL"
Performance Issue on HP-UX 10.20
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: C script

Hi:

This is pretty simple:

I've deliberately done this is K&R C rather than ANSI C but you can change the protypes if you like:

#include
#include

int main(argc,argv)
int argc;
char *argv[];
{
int cc = 255;
char s_cmd[1024];

if (argc > 1)
{
(void) sprintf(s_cmd,
"rsh -l oracle192.100.100.100 /export/home/oracle/test.sh %s",argv[1]);
cc = system(s_cmd);
printf("%d\n",cc);
}
return(cc);
}


If it ain't broke, I can fix that.
Wodisch
Honored Contributor

Re: C script

Hello,

I would recommend to check for semicolons or pipes in the string passed as parameter to NOT allow anything else to be executed!
Just imagine someone calls your script or C-program like that:

program "silly; rm -rf /"

See my point?

Just my $0.02,
Wodisch