hi
I wanted to access the C program variables in shell script.
This script is called from the same C program.
What are the ways in which i can access variables
thankx
hi
I wanted to access the C program variables in shell script.
This script is called from the same C program.
What are the ways in which i can access variables
thankx
Pass some variables to the script as parameters
char cmd[256]={0x0};
sprintf(cmd,"%s %d %s","myscript.sh", intCvariable, strCvariable);
or check into popen which lets the C code write to stdin of the script.
man popen
Jim's way or Try using putenv to put the values you need in the environment.
as u said i have written the code as
------------------------------------------------------------------------------------------------------------------------------
int main()
{
int a;
char b[10];
char cmd[256]={0x0};
printf\("\\nenter the value of a : "\);
scanf\("%d",&a\);
printf\("\\nenter val of b[] : "\);
scanf\("%s",b\);
sprintf\(cmd,"%s %d %s","test1.sh",a ,b\);
system\(cmd\);
return 0;
}
------------------------------------------------------------------------------------------------------------------------------
the output :
enter the value of a : 1
enter val of b[] : sammmm
sh: test1.sh: command not found
------------------------------------------------------------------------------------------------------------------------------
and in test1.sh :
echo "in test1.sh file"
------------------------------------------------------------------------------------------------------------------------------
can u please tell me why this error is comming and also the way through i can access
the variables in script file