Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overwrite original profile from C 1

Status
Not open for further replies.

chece

Programmer
Apr 14, 2003
2
SG
Hi,

I'm trying to overwrite my setup environment profile with other profile, which I execute it from a C program:
system("#!/bin/ksh \". ora_env\"");
There is no compilation and runtime errors, but I can't get the env inside ora_env.
Please advise.
Thanks.

 
Two problems with that:

1. The line you pass to system begins with #. That means the entire thing is a comment, so your entire program essentially tries to executes a comment. Just execute the script or, if it's not executable, pass it to ksh (or another shell). But...

2. Even if you got that right, system would just open a shell, execute the command, the environment would be changed in that shell, then that shell would die, and you'd be back in the C program. The program would die, and you'd be back on the original shell. In other words, it would do next to nothing.


If you want to load the environment in your original shell, just use the . command.

If you want to load the environment for your C program without changing your original shell's environment, I'd write a shell-script wrapper around the C program to load that ora_env, then execute the program.
 
Hi,
Thanks a lot.
I write a shell script wrapper around C prog, and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top