By rafae11
I new to unix im generating a script within c code.
I need to upgrade the software to a newer version and in need su privilege.
what is the correct syntax in running su within the script?
i would greatly appreciate your help
many thanks
rafael
/* Y o u r D e s c r i p t i o n */
/* AppBuilder Photon Code Lib */
/* Version 2.03 */
/* Standard headers */
#include
#include
#include
#include
#include
#include
#include
/* Local headers */
#include "ablibs.h"
#include "AppGlobal.h"
#include "abimport.h"
#include "proto.h"
#include "version.h"
#include
#include
struct stat sb;
using namespace std;
int
Yes( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
// find where abc/123/version x is located
system("find /fs/*/abc/123/*/ > /root/find.txt");
// only read the first result
std::string line;
std::ifstream stream("/root/find.txt");
getline(stream,line);
// current version
int maj = VERSION_MAJOR;
int min = VERSION_MINOR;
int pat = VERSION_PATCH;
// comparing to
int maj_comp = 0;
int min_comp = 0;
int pat_comp = 0;
// check if it is a valid folder
if (stat(line.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode))
{
unsigned found = line.find_last_of("/");
stringstream line_to_int;
line_to_int << line[found-5];<br ...read more
Source: FULL ARTICLE at The UNIX and Linux Forums