setenv function in C programming


 
Thread Tools Search this Thread
Top Forums Programming setenv function in C programming
# 1  
Old 05-11-2007
Question setenv function in C programming

Hi

I have a problem with setenv function in C. I'm calling an .exe of a c program from my shell script. Now, I have to pass a value from the .exe to my shell script. So i have exported an variable in my script. And in the C program I'm setting the variable as

setenv("REC_CNT",rec_cnt,1);

where rec_cnt is the string pointer variable. REC_CNT is the shell variable I'm exporting. But when I compile my C program, I'm getting the following error.

/usr/ccs/bin/ld: Unsatisfied symbols:
setenv (first referenced in sample.o) (code)

Can someone help me with this ?

Thanks,
Jane A
# 2  
Old 05-11-2007
setenv is defined in stdlib.h - this means it is part of libc, which is brought in by default.

Are you sure there are no goofy or extra characters in "setenv" in the text of the code?

Code:
cc sample.c -o sample

is the command you used, correct?
# 3  
Old 05-14-2007
Nope ! There are no extra characters in the function.
Mine is a Pro C file. I compiled it using Makefile.
# 4  
Old 05-14-2007
What OS are you using? Your makefile may have an error. Compile the program without using make.
# 5  
Old 05-14-2007
I am working in Unix Environment. Can you please tell me how to compile a Pro C file without a make ?
# 6  
Old 05-14-2007
"Unix environment" does not tell us what OS you are using. Run the command "uname -a" and post the results. I don't know what "Pro C" is supposed to mean. The command that Jim gave is how you compile a C program.

cc sample.c -o sample
# 7  
Old 05-14-2007
I am using HP-UX B.11.11. With Pro C I mean Pro* C.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

setenv: cannot add the LD_LIBRARY_PATH

Hi all! I need to add new environment variable. e.g. # setenv LD_LIBRARY_PATH "/usr/ucblib:" # I check:# env LD_LIBRARY_PATH=/usr/ucblib: After rebooting I don't see this variable. Why don't save this variable? Thanks. (5 Replies)
Discussion started by: wolfgang
5 Replies

2. Programming

Please help! accept function problems in Socket programming

Hi, I have a client-server socket program. It has been working fine for over a year, but recently it started to show strange behavior.:confused: After the server program runs for a while, it will show in the top command saying it is using lots of CPU, MEM. I assume it means the server code is... (1 Reply)
Discussion started by: natxie
1 Replies

3. UNIX for Advanced & Expert Users

setenv.

helllo every body .. hope you are having good time programming in unix . here is a little problem faced me : setenv("myvar","bla bla",1); system("myvar=$(grep....)); printf("%s\n", getenv("myvar")); will print : bla bla .. how can i get the value of grep into my program ? ... (7 Replies)
Discussion started by: max_475
7 Replies

4. Programming

connect() function in C++ socket programming

Hello All, I have a problem using connect(...) function in C++. I am using SSH from my windows system to connect it to linux server. The program works fine if I run it directly in Linux machine but I need it to run through windows machine. The function returns -1 and so my program terminates. ... (3 Replies)
Discussion started by: smdhd3
3 Replies

5. Shell Programming and Scripting

setenv error

I am having the following environment setup script. $cat dbenv.sh #! /bin/csh # set history=32 stty sane setenv ORACLE_HOME=/dboracle/orabase/product/10.1.0.3 set ORACLE_BASE=/dboracle/orabase set... (2 Replies)
Discussion started by: rahulrathod
2 Replies

6. Shell Programming and Scripting

awk programming and sub function

I'm trying to use awk function sub or even gsub to search a file and replace all occurences of "$curYear|" with "$curYear ". I need to remove the pipe delimator from only that field. I'm getting awk: syntax error near line 1 awk: illegal statement near line 1 with this use in my ksh... (4 Replies)
Discussion started by: cubs0729
4 Replies

7. Shell Programming and Scripting

setenv in script

Is it possible to set environement variable in a script (for example, perl script) so that the variable will be set after exiting the script - in a father shell. (2 Replies)
Discussion started by: kosta_mirkin
2 Replies

8. Shell Programming and Scripting

What 's setenv?

Hi Is someone know about "setenv"? where can i find out this one? Regards Myoe (2 Replies)
Discussion started by: myoeminn
2 Replies

9. UNIX for Dummies Questions & Answers

set, setenv

Well first of all I am a real Unix newbie. I am taking a course on it in University. I kind of understand set and setenv but, I think it si something that I should really understand. So I thought that I would try a forum out and see how good you guys really are. The question: Execute the... (1 Reply)
Discussion started by: w6u6f
1 Replies

10. UNIX for Dummies Questions & Answers

setenv Question

I want to add paths to a CLASSPATH variable but if I use the : setenv CLASSPATH /opt all previous entries are erased. How do I append additional entries to a system variable without overwriting the original value. Thanx (3 Replies)
Discussion started by: ianf
3 Replies
Login or Register to Ask a Question