Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing C code is for LINUX based system to create a menu instead of a command prompt that requires long commands to be typed. It prints our directories and files in the current working directory. The 'r' command in the switch case should run an executable file. The user will be prompted to enter the number for the file or the name from the given list to be executed but I am not aware as to what commands to use to implement it.

What I have tried:

I have tried use system() but that has not helped.
Posted
Updated 18-Sep-16 15:51pm
v4

1 solution

'has not helped' doesnt really tell us why not/what you're looking for - you could try the exec_prog() function outlined here How do I execute external program within C code in linux with arguments? - Stack Overflow[^]

.. since you dont say whether you want the output captured for example, its a bit hard to offer more help (the quality of help is in direct proportion to the quality of the requirements/question)
 
Share this answer
 
Comments
[no name] 18-Sep-16 21:54pm    
Sorry for the vague question. I tried posting the code but it was too long and I could not decide which part to post. The output does not need to be captured. I will make sure I go through the stack overflow link before asking further help.
Garth J Lancaster 18-Sep-16 22:07pm    
cool - I'd also start with a simple thing to run - iirc, there's nothing to stop you doing a 'redirect' of your output to a text file to make sure you're getting something from the exe or using something like

&& echo date +"%m/%d/%Y %H:%M:%S" > /some path/tracefile.txt

at the end of your command just so you know something happened

CPallini 19-Sep-16 3:13am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900