![]() |
|
#1
|
|||
|
|||
Call a C program through Linux shell scriptHi all,
I have a bit strange issue. I have a shell script that fetch some information to shell variables and calls a C program with those shell variable.(14 variables passed). However when this executes I miss one or two parameter values in the C program. (but not all). When I printf the values one by one argv[x] displays all the values. However even this If I use the following it prints with some missing Charaters. printf("1:%s \n",argv[1]); printf("2:%s \n",argv[2]); printf("3:%s \n",argv[3]); printf("4:%s \n",argv[4]); printf("5:%s \n",argv[5]); printf("6:%s \n",argv[6]); printf("7:%s \n",argv[7]); printf("8:%s \n",argv[8]); printf("9:%s \n",argv[9]); the output looks like this. 1:abcde :abcde@domain.lk :192.168.1.249 4:2004-2-29 22:05:46 :abcde@yahoo.com 6:0 7:0 :test-xp-01 9:email.content 0:1 11:0 12:0 13:1 14:email.envelope With missing printf characters. 2,3,5,8 and character 1 of 10 is missing. After I assign the parameter to C variables with strcpy() and the printf returns the following. 1:abcde 2: :192.168.1.249 4:2004-2-29 22:05:46 :abcde@yahoo.com 6:0 7:0 :test-xp-01 9:email.content 0:1 11:0 12:0 13:1 14:email.envelope Here I am using Bash shell on a Redhat 9.0. I tried with different version but the results same. However when I call the C program directly it outputs correctly. The problem exists only with Shell script and C integration. I tried gcc versions gcc version 2.96 and gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7). Please help me. I am stuck. Sorry for the long description. Thanks |
|
#2
|
|||
|
|||
|
Post the program and the shell script.
here's my shellscript (I've used '\' so that the listing won't be too wide to see here). My program name is "shelltest". Quote:
Does your program process this OK? If so, what's your shell script look like? If not, what's your program look like? Dave |
|
#3
|
|||
|
|||
|
Quote:
############################ Thanks for the reply. Yes Of cause it process fine when I call the C program through Shellscript with real values as you did. But if I replace those values with shell variable the problem occurs. |
|
#4
|
|||
|
|||
|
Quote:
Well, maybe someone can help you, but I can't magically see what you are trying to do. Sorry. Dave |
Recent GIDBlog
A Week in Kuwait by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mozilla Thunderbird | dsmith | Computer Software Forum - Linux | 9 | 01-Mar-2005 11:56 |
| Changing monitors on a Linux machine | JdS | Computer Software Forum - Linux | 10 | 23-Dec-2004 09:49 |
| Linux Kernel Upgrade Mini Howto | dsmith | Computer Software Forum - Linux | 3 | 05-Apr-2004 22:10 |
| JavaScript Tutorial Part 1 | pcxgamer | Web Design Forum | 2 | 01-Dec-2003 09:16 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The