09-10-2008
problem accessing Multiple Variables from C Program to a Shell script
program name--test
#!/bin/bash
output1=`/home/user/a.c`
output2=`/home/user/a.c`
k=`$output1 + 1`
m=`$output2 + 1`
echo $k
echo $m
---------------------------------------------------------------------------
prgram name--a.c
#include<stdio.h>
int main()
{
int i,j;
printf("Enter Values ::");
scanf("%d %f",);
snprintf(s, 100, "echo %d","echo %d",i,j);
system(s);
return 0
}
-------------------------------------------------------------------------
my requirement is to access the variable from C program as a simple input,pass the value of two variables to the script
which will manipulate the value and display
main thing is : not to execute c Program first,.we have to excute ./test first in console
Problem is I did not pass those two variable to the script.
Is there any way to pass the value of those variable from C program?please help me out...i an sending error message..thanks to all
[user@localhost ~]$ chmod 777 a.c
[user@localhost ~]$ chmod 777 test
[user1@localhost ~]$ ./test
/home/user/a.c: line 3: syntax error near unexpected token `('
/home/user/a.c: line 3: `int main()'
/home/user/test.c: line 3: syntax error near unexpected token `('
/home/users/test.c: line 3: `int main()'
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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 (3 Replies)
Discussion started by: bhakti
3 Replies
2. Shell Programming and Scripting
Hello,
I wonder if it is possible to pass and use variables from shell environment into sed or awk. I am trying to achieve something similar to the following using sed or awk:
var=some_regular_expression
grep "$var" filename # Will extract lines from filename
The following code,... (3 Replies)
Discussion started by: nasersh
3 Replies
3. Shell Programming and Scripting
I have a variable $exe in a shell script file a.sh which I need to access in another shell script file b.sh. How can I do that? :rolleyes:
Thanks!! (2 Replies)
Discussion started by: looza
2 Replies
4. Shell Programming and Scripting
Hi,
I have a shell script wherein i am doing some file operations and storing the data in some variables. I am exporting these variables as i need to use them outside shell. Then within the shell i am launching GDB session hoping that i will be able to access the exported variables in the GDB... (2 Replies)
Discussion started by: jsantosh
2 Replies
5. UNIX for Advanced & Expert Users
Hello All,
I was just wondering if there is any direct way to access PL/SQL OUT variables from Korn Shell Script.
I could already figure out how to return a single value back from PL/SQL to Shell Script (using bind variable).
But, what if we want to return multiple values?
One option I... (4 Replies)
Discussion started by: bright_future
4 Replies
6. Shell Programming and Scripting
Hi All,
I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh.
For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access... (2 Replies)
Discussion started by: rsendhilmani
2 Replies
7. Shell Programming and Scripting
Hi,
I want to access a variable outside the awk program. My program is as below:- I can not access the exact value of k (See the last line of the program).
#!/usr/bin/sh
j=10
k=1
#k is declared outside awk
awk '
BEGIN {
i=1;
j1="'"$j"'"
printf("\n ## Value of j1 is %d ##", j1);
... (2 Replies)
Discussion started by: shouvik.mitra
2 Replies
8. UNIX for Dummies Questions & Answers
Hello,
So I have approximately 300 files of raw data (.txt) files that I am using to perform statistical analysis. I have been able to construct a Fortran program that is able to perform my statistical analysis on a file by file basis.
However, I now want to be able to loop program through... (19 Replies)
Discussion started by: Jimmyd24
19 Replies
9. Linux
how to store the count of queries in variables inside a filein shell script
my output :
filename
-------
variable1=result from 1st query
variable2=result from 2nd query
.
.
.
. (3 Replies)
Discussion started by: sanvel
3 Replies
10. Programming
Hi,
Can anyone explain this please..... This is on AIX with GDB (tried a few versions). It only happens when program compiled in 64 bit and only with static variables....
A simple test program...
### snip
#include <stdio.h>
main() {
static int n;
n = 6;
printf("hello %d\n", n);... (0 Replies)
Discussion started by: bagpussnz
0 Replies
LEARN ABOUT DEBIAN
wibble-test-genrunner
wibble-test-genrunner(1) General Commands Manual wibble-test-genrunner(1)
NAME
wibble-test-genrunner - Code generator for wibble testsuites.
SYNOPSIS
wibble-test-genrunner header <file>
wibble-test-genrunner main <files>
DESCRIPTION
The program generates .cpp files that are then compiled and linked into a test program for running tests from .test.h files. Examples of
such .test.h files may be found among wibble headers, eg. /usr/include/wibble/regexp.test.h.
In the first form, the program processes a single header file (usually of the form foo.test.h) and produces a corresponding .cpp file to be
compiled. In the second form, it takes as <files> all the .test.h headers and produces a single main.cpp which contains the main() function
of the test program, which then runs all the tests in all the .test.h files. The generated source code is always written to standard output
and it is left up to the user to redirect it to a meaningful location.
The program currently has no options other than the two forms above. The program is intended to be run as part of build process of programs
or libraries using the wibble testing framework. For convenient use from CMake, there is a test.cmake script under /usr/share/wibble, that
takes care of producing all the .cpp files (both per-header and the main one), compiling them and linking them into a single binary which
executes the testsuite.
AUTHOR
Petr Rockai <me@mornfall.net>
wibble-test-genrunner(1)