ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can i access the Shell variable(PATH) in c program.
Actually i am running a command in C program using "system", which will update the shell variable "COUNT" continuously. I need to access the COUNT after every second in a c program.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
Quote:
Originally Posted by navin_karnam
Actually i am running a command in C program using "system", which will update the shell variable "COUNT" continuously.
If I understand correctly what you are doing, this isn't going to work.
The COUNT variable you are modifying with system is local to the system subshell, and unreachable from anything else.
I came to know how i can access the environment variables in c program..
But it is not solved my main problem still .. I will explain my problem clearly.
1) I have to display the progress of the command "tar zxf largesize.tgz"
2) To uncompress it is taking more than 10 min.
3) The above things i have to do in a c program and i have to display the progress of uncompressing.
4) To do the above I tried running the process in background using :
system ( " tar zxf largesize.tgz > temp & " );
But i dont know how i can check the progress of the background process.
Please help me out in solving this problem, or guide me is there any other good procedure which suits my requirement..
I came to know how i can access the environment variables in c program..
But it is not solved my main problem still .. I will explain my problem clearly.
1) I have to display the progress of the command "tar zxf largesize.tgz"
2) To uncompress it is taking more than 10 min.
3) The above things i have to do in a c program and i have to display the progress of uncompressing.
4) To do the above I tried running the process in background using :
system ( " tar zxf largesize.tgz > temp & " );
But i dont know how i can check the progress of the background process.
Please help me out in solving this problem, or guide me is there any other good procedure which suits my requirement..
Use popen() instead of system(), and read the output of your command (perhaps use tar xvzf).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.