The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-28-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Arrow

Hi ,

I have found a solution for this and it is working !!
Let the two files involved here be sample.c and 1.sh
Open the sample.c
(My program was as below)

# include <stdio.h>
void pline(void);
main(int argc,char *argv[])
{
int i,j;

printf("Wow Entered main\n");

i=strcmp(argv[0],"pline"); /*just to test*/
j=strcmp(argv[1],"pline"); /*just to test*/
printf("i=%d \n j=%d\n",i,j);

if(strcmp(argv[1],"pline") == 0)
{
pline();
printf("done\n");
}
}

void pline(void)
{
int i;
for(i=1;i<5;i++)
printf("Test \n");
printf("\n");
}

Now save the sample.c and execute it so that we get the .exe file
The command for this is :
gcc -o sample.exe sample.c

Now this will give us sample.exe file

Now open the 1.sh

echo " test script to call the c function"
sample.exe pline

save the script and execute it !!!!

Note that either we have to include the patch of sample.exe in the $PATH (environment variable) or give the complete path of sample.exe in the example script as below:


echo " test script to call the c function"
/home/name/script/sample.exe pline

thanks
Js