I need to know if xclip (the command is installed) because if it is available I want to send a command to it via the system() function, otherwise I want to display a message. Is there a way to know if the command exists?
Thanks
I mean programably
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For something like xclip, you can just do:
and check the return value. A -1 indicates that xclip was not found. Or, you can execute something like:
and check for a 0 return, indicating no failed arguments.