I am using following function inside container to execute command line argument cd /mypath && sha1sum -c mysha1sumfile
to compare the sha1sum of files available in /mypath with the values in mysha1sumfile in the same path. The command is working in when I execute it as binary. The same is working when I tried manually inside the container by executing /bin/bash (inside container). But not working from the program.
executeCmd(const char* command)
{
string response = "";
char buffer[256];
FILE* pipe = popen(command,"r");
if(!pipe) {
response = "ERROR";
}
while(!feof(pipe)){
if(fgets(buffer,128,pipe) != NULL){
response += buffer;
}
}
pclose(pipe);
return response;
}
Verified that pipe
is not NULL
and feof(pipe)
is also not NULL
. But fgets()
returning NULL
.
What can cause that?
Thank's for your comment. I could resolve the issue. It was due to a missing library libtinfo.so.5 for shell scrip ("sh") inside the container. After the library has been copied to /lib/ inside the container it started working
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.