Sponsored Content
Top Forums Programming Returning Strings from C program to Unix shell script Post 94369 by Corona688 on Thursday 29th of December 2005 08:03:40 PM
Old 12-29-2005
Quote:
Originally Posted by linuxpenguin
Hey, you had the idea yourself, sending the password string to environment. Go aheas and do a
strcpy(string, env_pass_var);
strcat(string, "=");
strcat(string, c_pass_var);
putenv(string)

access this in shell script by $value_of_env_pass_var
Will Not Work™©®.

The C program inherits a copy of the environment variables of the shell, and the changes don't go back, they stay in the C program. The changes would be inherited by other programs the C program lanuches, but not the original shell.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Returning Values (shell Script)

I have an application on Informix 4GL, and I am invoking the shell script from the program, but I need to know if the shell script work fine or not, in order to continue the process. I know that we can use $? to get the final status but this is on unix command. How can I return a value from the... (3 Replies)
Discussion started by: jennifer01
3 Replies

2. Shell Programming and Scripting

shell program for sorting strings in an alphabetical order

Hi, I trying to find the solution for writing the programming in unix by shell programming for sorting thr string in alphabetical order. I getting diffculty in that ,, so i want to find out the solution for that Please do needful Thanks Bhagyesh (1 Reply)
Discussion started by: bp_vanarse
1 Replies

3. Programming

Returning Strings from C program to Unix shell script

Hi, I'm having a requirement where I need to call a C program from a shell script and return the value from the C program to shell script. I refered a thread in this forum. But using that command in the code, it is throwing an error clear_text_password=$(get_password) Error: bash:... (24 Replies)
Discussion started by: venkatesh_sasi
24 Replies

4. AIX

The shell script is not returning proper result

Can anybody pls look into this script and tell me where I went wrong. After running this script, it is showing like "Trying to overlay current working directory ABORT!!!" :-( ARGCNT=$# if then echo "Two parameters are needed for this shell " echo "Please try again with... (1 Reply)
Discussion started by: clnsharma123
1 Replies

5. Shell Programming and Scripting

Can we pass an array of strings from a Perl Program to a Shell Script?

Hi Folks, The subject is my question: Can we pass an array of strings from a Perl Program to a Shell Script? Please provide some sample code. Thanks ---------- Post updated at 11:52 PM ---------- Previous update was at 11:43 PM ---------- I got it. Its here:... (0 Replies)
Discussion started by: som.nitk
0 Replies

6. Shell Programming and Scripting

Returning to shell from previous script

Found myself stuck on this seemingly trivial issue. I have this script which call other shell files to do their deeds. The shell files in turn call some other programs as well. My problem is that in two of these shell files, the control doesnt return to next command in script unless the Enter key... (2 Replies)
Discussion started by: DoesntMatter
2 Replies

7. Shell Programming and Scripting

how to execute a unix shell script from a java program

Hi All, well , i am facing this problem.. i have tried a few sample codes but there isn't any solution . could anyone please give a sample code as of how to do this... Please see the below details...and read the details carefully. I have written some code, logic is 1)from... (4 Replies)
Discussion started by: aish11
4 Replies

8. Shell Programming and Scripting

Control from UNIX script is not returning to the Parent program

Hi All, My program flow is as below Windows batch -- > Cygwin batch --> zsh script There are multiple Cygwin batch scripts that are called from Windows batch file . But when i am executing the first cygwin batch script the control goes to the zsh file and executes and stoping from... (1 Reply)
Discussion started by: Hypesslearner
1 Replies

9. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have a UNIX script which will prepare anonymous oracle pl/sql block in a temporary file in run time and passes this file to sqlplus as given below. cat > $v_Input_File 2>>$v_Log << EOF BEGIN EXECUTE IMMEDIATE 'ALTER SESSION FORCE PARALLEL DML PARALLEL 16'; EXECUTE... (1 Reply)
Discussion started by: vikas_trl
1 Replies

10. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have exactly same issue @vikas_trl had in following link: https://www.unix.com/shell-programming-and-scripting/259854-control-not-returning-sqlplus-calling-unix-shell-script.html I wonder if he or somebody else could find the issue's cause or the solution. Any help would... (4 Replies)
Discussion started by: RicardoQ
4 Replies
putenv(3)						     Library Functions Manual							 putenv(3)

NAME
putenv - Sets an environment variable LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdlib.h> int putenv( const char *string); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: putenv(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to a name=value string. DESCRIPTION
The putenv() function sets the value of an environment variable by altering an existing variable or by creating a new one. The new envi- ronment variable remains in effect even after the program setting it is exited. The string parameter points to a string of the form "name=value", where name is the environment variable and value is the new value for it. NOTES
The putenv() function manipulates the environ external variable, and it can be used in conjunction with the getenv() function. However, the third parameter to the main function (the environment pointer) is not changed. The putenv() function uses the malloc() function to enlarge the environment. A potential error is to call putenv() with an automatic variable as the argument and then exit the calling function while string is still part of the environment. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the malloc() function is unable to obtain sufficient space to expand the environment, the putenv() function returns a nonzero value. RELATED INFORMATION
Functions: clearenv(3), exec(2), getenv(3), malloc(3) Standards: standards(5) delim off putenv(3)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy