How to execute .sh file from different directory though a c++ Program
Hello,
Sorry if this is not correct place for posting this but i was trying to write a short c++ code to choose different conky's. Code:
switch(choice) 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. Any help?!!?!? PS: i know case 5 is commented. |
Why C++? Why not just use bash?
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? |
Do you have a
Code:
#!/bin/bash The OS needs to understand how to run the shell. If not try: Code:
/bin/bash <script to run> <command line parameters> |
for execl to able to execute a script it requires #!/bin/bash as the first line.
|
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
Code:
system("~/.conky_config_files/.GoldnGrey/conky.sh"); |
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. Code:
system("chmod +x ~/.conky_config_files/.GoldnGrey/conky.sh"); But how to hide that terminal??? i wish to hide terminal when execution of conkyrc is done.. |
Hm... Like I said, I'm pretty sure it's conky making that terminal. Look:
Code:
/* ~/test/test.cpp */ Code:
#!/usr/bin/env bash Code:
$ ls -l 1file.bash |
All times are GMT -5. The time now is 05:59 AM. |