Sponsored Content
Top Forums Shell Programming and Scripting problem accessing Multiple Variables from C Program to a Shell script Post 302234889 by jim mcnamara on Wednesday 10th of September 2008 04:56:16 PM
Old 09-10-2008
one second thought: This has to be homework.

export the variables in shell script - in C call getenv() to retrieve the variable's value.

Code:
export plpl="SOMEVALUE"

Code:
#include <unistd.h>
..........
........
printf("%s\n", getenv("plpl");

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to access the C program variables in shell script

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

Accessing Shell Variables in awk or sed

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

Accessing variables of one shell script in another shell script

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

Problem in accessing variables outside shell

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

Accessing PL/SQL OUT variables in Korn Shell Script

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

Accessing variables of one shell script in another shell script

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

Accessing variable from awk program in shell

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

Using Shell Script To Loop Program Through Multiple Text Files

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 count of multiple queries in variables in a shell script?

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

GDB problem accessing static variables in C

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
getenv(3)						     Library Functions Manual							 getenv(3)

NAME
getenv - Returns the value of an environment variable LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdlib.h> char *getenv( const char *name); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: getenv(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the name of an environment variable. DESCRIPTION
The getenv() function searches the environment list for a string of the form name=value, and returns a pointer to a string containing the corresponding value for name. The returned string should not be modified by the application, but may be overwritten by a subsequent call to the getenv() or putenv() functions from the same thread. RETURN VALUES
The getenv() function returns a pointer to a string containing the value in the current environment if such a string is present. If such a string is not present, a null pointer is returned. RELATED INFORMATION
Functions: putenv(3), clearenv(3) Commands: sh(1) Standards: standards(5) delim off getenv(3)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy