mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
helpers: add "backtick" function for shell-like command
Origin commit data
------------------
Branch: ni/coolstream
Commit: f607fe5fbe
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2015-02-08 (Sun, 08 Feb 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
committed by
Jacek Jendrzej
parent
bb5fbb9954
commit
2ea2d02303
@@ -361,6 +361,23 @@ std::string find_executable(const char *name)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string backtick(std::string command)
|
||||||
|
{
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t n = 0;
|
||||||
|
pid_t pid;
|
||||||
|
FILE *p = my_popen(pid, command.c_str(), "r");
|
||||||
|
if (! p)
|
||||||
|
return "";
|
||||||
|
std::string out = "";
|
||||||
|
while (getline(&buf, &n, p) >= 0)
|
||||||
|
out.append(std::string(buf));
|
||||||
|
free(buf);
|
||||||
|
fclose(p);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
std::string _getPathName(std::string &path, std::string sep)
|
std::string _getPathName(std::string &path, std::string sep)
|
||||||
{
|
{
|
||||||
size_t pos = path.find_last_of(sep);
|
size_t pos = path.find_last_of(sep);
|
||||||
|
@@ -55,6 +55,8 @@ bool get_mem_usage(unsigned long &total, unsigned long &free);
|
|||||||
void mySleep(int sec);
|
void mySleep(int sec);
|
||||||
|
|
||||||
std::string find_executable(const char *name);
|
std::string find_executable(const char *name);
|
||||||
|
/* basically what "foo=`command`" does in the shell */
|
||||||
|
std::string backtick(std::string command);
|
||||||
|
|
||||||
bool hdd_get_standby(const char * fname);
|
bool hdd_get_standby(const char * fname);
|
||||||
void hdd_flush(const char * fname);
|
void hdd_flush(const char * fname);
|
||||||
|
Reference in New Issue
Block a user