[SOLVED] How to execute .sh file from different directory though a c++ Program
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
My case 5 is not working, tried almost evrything on internet.
I dont know much bash coding. In this program i was trying to execute conky.sh from any directory.
Also, i want to hide the terminal on which i execute this program.
For closing the terminal, I'm pretty sure you can configure conky to jump to fork or run as a daemon or do some kind of magic so that it will not be a child process of your program, and so you can run 'xterm -e "your_program"' and the terminal will close after it's finished but conky won't... I think it's the "background yes" .conkyrc option, but can't remember offhand.
Finally, what commands are you trying to run in case 5? (i.e. if you were doing it manually, from a terminal, what commands would you want to enter?
Distribution: Slackware 14, Debian 7.0.0 Wheezy, Windows 7, Windows 8
Posts: 117
Original Poster
Rep:
I just wanted to create a simple gui to select from different conky configuration. Can i do that with bash coding?
And in case 5 i only tried to run script "~/.conky_config_files/.GoldnGrey/conky.sh" from different directory, say from Desktop!
Ah, if you're creating a GUI, then stick with C++. Have you checked it's a) executable (or run "chmod 755 <filename>", assuming you own the file) b) has the "#!/usr/bin/env bash" line at the start, as other people suggested? Then you should just need to have
to run it. Also, it may be worth putting some 'echo' code (or even use 'xmessage') in your conky.sh file, so you can check it runs - it is entirely possible that your C++ code is running the file correctly, but for some reason conky isn't starting, in which case the bug squashing needs to be done on that code, not your C++.
Distribution: Slackware 14, Debian 7.0.0 Wheezy, Windows 7, Windows 8
Posts: 117
Original Poster
Rep:
Snark
Thanks, As i was coding in cpp,adding "#!/usr/bin/env bash" didn't work nor in system(""). But making file executable before executing it, helps.
ie.
This doesn't open a terminal for me, just prints the output to the terminal already running. And if I run the script from my desktop, then no terminal opens. Can we see the contents of the script you're running? (also, you shouldn't need to run chmod every time - only once. So you can remove that line from your code)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.