I’m trying to work with Terminal commands from OF and though i’m getting some other requests i’m unable to run a file search command:
if I run on Terminal :
find ~/ -iname "anaglyphDemo.zip"
i get the file path back, however using ofSystem i get an error from the result string:
I’ve tried hardcoding the command and get the same result,
here’s how I’m composing the file string,
string fileNAME = "fileName.jpg";
string aspas = "\"";
string fileNAMEASPAS = aspas + fileNAME + aspas;
cout << fileNAMEASPAS <<endl;
string fileCMD = "find ~/ -iname " + fileNAMEASPAS ;
cout << fileCMD <<endl;
string filePATH = ofSystem(fileCMD);
cout << " --> " <<filePATH << endl;
does anyone know what is this error? or has some experience with Terminal commands?
i think i just figured it out,
needed to authenticate the session…
changed the cmdString to
string fileCMD = "echo “password” | sudo -S find / -name " + fileNAMEASPAS ;
some errors on the console but getting the path!
I’ve came up with this same issue in OSX.
I enden up using “system” by itself instead of ofSystem. ofSystem uses popen and it apparently needs some kind of authentication which I can not seem to find.
The weird thing is that the first command sent through ofSystem actually works. After that you get the /377.
I’m not sure whether it’s a bug in the latest oF release.
I just ran into this problem myself - it’s a bug in OF. Here’s a fix- inside the ofSystem() function in ofUtils.cpp, there is a call to ‘fclose(ret)’, change this to ‘pclose(ret)’.
Just opened an issue on github: https://github.com/openframeworks/openFrameworks/issues/2940