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

C++ runcmd函数代码示例

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

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



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

示例1: setacl

static void setacl(int index, int zoom, int x, int y)
{
	LOGI("%i: zoom=%i, x=%i, y=%i", index, zoom, x, y);

	char cmd[256];
	if(g_mode == MODE_NED)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/ned/%i/%i_%i.nedgz", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_OSM)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/osm/%i/%i_%i.pak", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_HEIGHTMAP)
	{
		snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/hillshade/%i/%i_%i.pak", zoom, x, y);
		runcmd(cmd);
	}
	else if(g_mode == MODE_BLUEMARBLE)
	{
		int month;
		for(month = 1; month <= 12; ++month)
		{
			snprintf(cmd, 256, "gsutil acl set -a public-read gs://goto/bluemarble/%i/%i/%i_%i.pak", month, zoom, x, y);
			runcmd(cmd);
		}
	}
}
开发者ID:jeffboody,项目名称:nedgz,代码行数:30,代码来源:setacl.c


示例2: __read

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
	if (!fd || !fd->data) {
		return -1;
	}
	int wordSize = 4;
	ut32 *w = (ut32*)buf;
	int i;
	memset (buf, 0xff, count);
	int words = count / wordSize; // XXX must pad align to 4
	for (i = 0; i < words ; i++) {
		ut64 addr = io->off + (i * wordSize);
		char *cmd = r_str_newf ("x 0x%"PFMT64x, addr);
		char *res = runcmd (cmd);
		sscanf (res, "%x", &w[i]);
		free (res);
		free (cmd);
	}

	int left = count % wordSize;
	if (left > 0) {
		ut32 n = 0xff;
		ut8 *wn = (ut8*)&n;
		ut64 addr = io->off + (i * wordSize);
		char *cmd = r_str_newf ("x 0x%"PFMT64x, addr);
		char *res = runcmd (cmd);
		sscanf (res, "%x", &n);
		free (res);
		free (cmd);
		memcpy (buf + (words * wordSize), wn, left);
	}
	return count;
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:32,代码来源:io_winedbg.c


示例3: runcmd

void runcmd(struct cmd *cmd)
{
  int p[2];
  struct execcmd *ecmd;
  struct pipecmd *pcmd;
  struct redircmd *rcmd;

  if(cmd == 0)
    exit(1);
  
  switch(cmd->type){
  default:
    printf("runcmd error!\n");

  case 1:
    ecmd = (struct execcmd*)cmd;
    if(ecmd->argv[0] == 0)
      exit(0);
    execvp(ecmd->argv[0], ecmd->argv);
    printf("exec %s failed\n", ecmd->argv[0]);
    break;

  case 2:
    rcmd = (struct redircmd*)cmd;
    close(rcmd->fd);
    if(open(rcmd->file, rcmd->mode) < 0){
      printf("open %s failed\n", rcmd->file);
      exit(0);
    }
    runcmd(rcmd->cmd);
    break;

  case 3:
    pcmd = (struct pipecmd*)cmd;
    if(pipe(p) < 0){
      printf("Errors in pipe!\n");
    }
    if(fork() == 0){
      close(1);
      dup(p[1]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->right);
    }
    if(fork() == 0){
      close(0);
      dup(p[0]);
      close(p[0]);
      close(p[1]);
      runcmd(pcmd->left);
    }
    close(p[1]);
    close(p[0]);
    wait(NULL);
    wait(NULL);
    break;
  }
  exit(0);
}
开发者ID:moodfamily,项目名称:CMPT332_a1_Shell,代码行数:59,代码来源:myshell.c


示例4: init_judge_environment

void init_judge_environment(int RunID, int language, char *workdir)
{
    sprintf(workdir, "%s/run%d", oj_home, RunID);
    runcmd("rm %s/errmsg/%d.err", oj_home, RunID);
    runcmd("rm -r %s", workdir);
    runcmd("mkdir %s", workdir);   
    runcmd("cp %s/code/%d %s/%s", oj_home, RunID, workdir, codename[language]);
}
开发者ID:PiraHzq,项目名称:pjudge,代码行数:8,代码来源:judge.c


示例5: main

int
main(void)
{
  static char buf[100];
  static char bufCNM[100];
  int fd;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
    if(fd >= 3){
      close(fd);
      break;
    }
  }
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      else{
        if((buf + 3)[0] == '.' && (buf + 3)[1] == '.' && (buf + 3)[2] == 0){
            cutChild(currentDir);
            if(currentDir[0] == 0) isRootDir = 1;
            continue;
        }
        if(isRootDir){
            catenate(currentDir, buf + 3);
            isRootDir = 0;
        }
        else{
            append(currentDir, '/');
            catenate(currentDir, buf + 3);
        }
      }
      continue;
    }

    if(fork1() == 0) {
      int i;
      int len = strlen(buf);
      for(i = len + 1; i > 0; i--) {
        bufCNM[i] = buf[i-1];        
      }   
      bufCNM[0] = '/';
      runcmd(parsecmd(buf));
      if(buf[0] != '/') {
        runcmd(parsecmd(bufCNM));
      }
      exit();
    }
    wait();
  }
  exit();
}
开发者ID:lishuwnc,项目名称:Xv6,代码行数:58,代码来源:sh.c


示例6: preparefiles

void preparefiles(char *dname, int len, char *workdir, char *datapath)
{
    char name[MAXLINE+1];
    strncpy(name, dname, len);
    name[len]='\0';
#ifdef DEBUG
    logerrmsg(judgelog, "name:#%s# %d copy %s/%s.in to %s/data.in", dname, len, datapath, name, workdir);
#endif
    runcmd("cp -a %s/%s.in %s/data.in", datapath, name, workdir);
    runcmd("cp -a %s/%s.out %s/data.out", datapath, name, workdir);
}
开发者ID:PiraHzq,项目名称:pjudge,代码行数:11,代码来源:judge.c


示例7: runcmd

// Execute cmd.  Never returns.
void
runcmd(struct cmd *cmd)
{
    int p[2], r;
    struct execcmd *ecmd;
    struct pipecmd *pcmd;
    struct redircmd *rcmd;
    
    if(cmd == 0)
        exit(0);
    
    switch(cmd->type){
        default:
            fprintf(stderr, "unknown runcmd\n");
            exit(-1);
            
        case ' ':
            ecmd = (struct execcmd*)cmd;
            if(ecmd->argv[0] == 0)
                exit(0);
            execvp(ecmd->argv[0], ecmd->argv);
            break;
        case '>':
        case '<':
            rcmd = (struct redircmd*)cmd;
            int is_out = cmd->type == '>';
            FILE* f = is_out ? freopen(rcmd->file, "w+", stdout) : freopen(rcmd->file, "r", stdin);
            runcmd(rcmd->cmd);
            fclose(f);
            close(fileno(f));
            break;
        case '|':
            pcmd = (struct pipecmd*)cmd;
            pipe(p);
            if (0 == fork()) {
                close(p[1]);
                close(0);
                dup(p[0]);
                runcmd(pcmd->right);
                exit(0);
            } else {
                close(p[0]);
                close(1);
                dup(p[1]);
                runcmd(pcmd->left);
                int r;
                wait(&r);
            }
            break;
    }
    exit(0);
}
开发者ID:molikto,项目名称:ExercisesAndCourses,代码行数:53,代码来源:sh.c


示例8: main

int
main(void)
{
  static char buf[100];
  int fd, r;

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        fprintf(stderr, "cannot cd %s\n", buf+3);
      continue;
    }
    /* also clumsy: can't use exit* programs, but ok since not 
      traversing PATH anyway.*/
    if(!strncmp(buf, "exit", 4)) {
	exit(0);
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait(&r);
  }
  exit(0);
}
开发者ID:dcashman,项目名称:Coursework,代码行数:27,代码来源:sh.c


示例9: main

int main(int argc, char* argv[])
{
    static char buf[BUFSIZ];
    int fd;

    whitespace = " \t\r\n\v";
    symbols = "<|>&;()";

    if (argc == 2 && !strcmp(argv[1], "-i"))
        interactive = 1;

    // Assumes three file descriptors open.
    while ((fd = open("/dev/console", O_RDWR)) >= 0) {
        if (fd >= 3) {
            close(fd);
            break;
        }
    }

    // Read and run input commands.
    while (getcmd(buf) >= 0) {
        if (!memcmp(buf, "cd ", 3)) {
            // Clumsy but will have to do for now.
            // Chdir has no effect on the parent if run in the child.
            if (chdir(buf + 3) < 0)
                dprintf(2, "cannot cd %s\n", buf + 3);
            continue;
        } else if (!strcmp(buf, "exit"))
            return 0; // XXX should allow return code (exit [n])
        if (fork1() == 0)
            runcmd(parsecmd(buf));
        wait();
    }
    return 0;
}
开发者ID:JianxinMa,项目名称:v9.js,代码行数:35,代码来源:sh.c


示例10: umain

void
umain(int argc, char **argv)
{
	int r, interactive, echocmds;

	interactive = '?';
	echocmds = 0;
	ARGBEGIN{
	case 'd':
		debug++;
		break;
	case 'i':
		interactive = 1;
		break;
	case 'x':
		echocmds = 1;
		break;
	default:
		usage();
	}ARGEND

	if (argc > 1)
		usage();
	if (argc == 1) {
		close(0);
		if ((r = open(argv[0], O_RDONLY)) < 0)
			panic("open %s: %e", argv[0], r);
		assert(r == 0);
	}
	if (interactive == '?')
		interactive = iscons(0);
	
	while (1) {
		char *buf;

		buf = readline(interactive ? "$ " : NULL);
		if (buf == NULL) {
			if (debug)
				cprintf("EXITING\n");
			exit();	// end of file
		}
		if (debug)
			cprintf("LINE: %s\n", buf);
		if (buf[0] == '#')
			continue;
		if (echocmds)
			printf("# %s\n", buf);
		if (debug)
			cprintf("BEFORE FORK\n");
		if ((r = fork()) < 0)
			panic("fork: %e", r);
		if (debug)
			cprintf("FORK: %d\n", r);
		if (r == 0) {
			runcmd(buf);
			exit();
		} else
			wait(r);
	}
}
开发者ID:AkshayRShukla,项目名称:mit-jos,代码行数:60,代码来源:sh.c


示例11: main

int
main(void)
{
  static char buf[100];
  int fd, r;

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        fprintf(stderr, "cannot cd %s\n", buf+3);
      continue;
    }
    if(strncmp(buf, "exit", 4) == 0) {
      fprintf(stdout, "Exit, good bye.\n");
      exit(0);
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait(&r);
  }
  exit(0);
}
开发者ID:yycsysu,项目名称:Operating-systems-6.828,代码行数:26,代码来源:sh.c


示例12: main

int
main(void)
{
  static char buf[100];
  int fd;

  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0) {
    if(fd >= 3){
      close(fd);

      break;
    }
  }

  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0) {
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    } else if(buf[0] == 'v' && buf[1] == 'e' && buf[2] == 'r' && buf[3] == 's' && buf[4] == 'i' && buf[5] == 'o' && buf[6] == 'n')
    	printf(1, "uNIX Version 0-1 \n Build Version 3");

    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait();
  }
  exit();
}
开发者ID:DylanEHolland,项目名称:Operating_Systems,代码行数:33,代码来源:sh.c


示例13: run

void
run(void)
{
	fd_set fs;
	int code;
	char **c;
	struct inotify_event ev;

	for (;;) {
		FD_ZERO(&fs);
		FD_SET(notfd, &fs);
		if (select(notfd+1, &fs, 0, 0, 0)==-1) {
			if (errno==EINTR || errno==EAGAIN)
				continue;
			perror("select");
			exit(1);
		}
		read(notfd, &ev, sizeof ev);
		if (ev.mask & IN_IGNORED
		&& inotify_add_watch(notfd, texfile, IN_MODIFY)==-1) {
			perror("inotify_add_watch");
			exit(1);
		}
		for (c=compile; *c; c++)
			if ((code=runcmd(*c))) {
				fprintf(stderr, "Command %s failed (%d)!\n",
					*c, code);
				break;
			}
//		if (code==0 && runcmd(reloadcmd)) {
//		err("Cannot sync xpdf, exiting");
//			exit(1);
//		}
	}
}
开发者ID:Telemin,项目名称:texwatch,代码行数:35,代码来源:texwatch.c


示例14: regState

static struct winedbg_x86_32 regState() {
	struct winedbg_x86_32 r = {0};
	char *res = runcmd ("info reg");
	if (res) {
		char *line = strstr (res, "EIP:");
		if (line) {
			ut32 eip, esp, ebp, eflags;
			(void)sscanf (line, "EIP:%08x ESP:%08x EBP:%08x EFLAGS:%08x",
				&eip, &esp, &ebp, &eflags);
			r.eip = eip;
			r.esp = esp;
			r.ebp = ebp;
			r.eflags = eflags;
			line = strstr (line, "EAX:");
			if (line) {
				ut32 eax, ebx, ecx, edx;
				(void)sscanf (line, "EAX:%08x EBX:%08x ECX:%08x EDX:%08x",
					&eax, &ebx, &ecx, &edx);
				r.eax = eax;
				r.ebx = ebx;
				r.ecx = ecx;
				r.edx = edx;
				line = strstr (line, "ESI:");
				if (line) {
					ut32 esi, edi;
					(void)sscanf (line, "ESI:%08x EDI:%08x", &esi, &edi);
					r.esi = esi;
					r.edi = edi;
				}
			}
		}
		free (res);
	}
	return r;
}
开发者ID:dtrecherel,项目名称:radare2,代码行数:35,代码来源:io_winedbg.c


示例15: R_EditFiles

/* As from R 2.7.0 we assume file, editor are in UTF-8 */
int R_EditFiles(int nfile, const char **file, const char **title,
		const char *editor)
{
    int   i;
    char  buf[1024];

    if (nfile > 0) {
	if (editor == NULL || strlen(editor) == 0)
	    editor = "internal";
	for (i = 0; i < nfile; i++) {
	    if (!strcmp(editor, "internal")) {
		Rgui_Edit(file[i], CE_UTF8, title[i], 0);
	    } else {
		/* Quote path if necessary */
		if (editor[0] != '"' && Rf_strchr(editor, ' '))
		    snprintf(buf, 1024, "\"%s\" \"%s\"", editor, file[i]);
		else
		    snprintf(buf, 1024, "%s \"%s\"", editor, file[i]);
		runcmd(buf, CE_UTF8, 0, 1, NULL, NULL, NULL);
	    }

	}
	return 0;
    }
    return 1;
}
开发者ID:csilles,项目名称:cxxr,代码行数:27,代码来源:system.c


示例16: forkcmd

static void
forkcmd(char *cmd, char *p, int reqfd, int datafd, int want_reply)
{
	char *q;

	switch (fork()) {
	case 0:
		if (restdir && chdir(restdir) < 0) {
			syslog(0, "ssh", "can't chdir(%s): %r", restdir);
			exits("can't chdir");
		}
		if (!prevent || (q = getenv("sshsession")) &&
		    strcmp(q, "allow") == 0)
			get_string(p+1, cmd);
		else
			confine(p+1, cmd);
		syslog(0, "ssh", "server running `%s' for %s", cmd, uname);
		/* runcmd doesn't return */
		runcmd(reqfd, datafd, "rx", "/bin/rc", "-lc", cmd);
	case -1:
		REPLY("failure");
		syslog(0, "ssh", "server can't fork: %r");
		exits("fork");
	}
}
开发者ID:99years,项目名称:plan9,代码行数:25,代码来源:sshsession.c


示例17: main

int
main(void)
{
  static char buf[100];
  int fd, status;
  
  // Assumes three file descriptors open.
  while((fd = open("console", O_RDWR)) >= 0){
    if(fd >= 3){
      close(fd);
      break;
    }
  }
  
  // Read and run input commands.
  while(getcmd(buf, sizeof(buf)) >= 0){
    if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
      // Clumsy but will have to do for now.
      // Chdir has no effect on the parent if run in the child.
      buf[strlen(buf)-1] = 0;  // chop \n
      if(chdir(buf+3) < 0)
        printf(2, "cannot cd %s\n", buf+3);
      continue;
    }
    if(fork1() == 0)
      runcmd(parsecmd(buf));
    wait(&status);
  }
  exit(0);
}
开发者ID:galmam,项目名称:OS152,代码行数:30,代码来源:sh.c


示例18: main

int
main ()
{
        runner_t runner;
        char buf[80];
        char *wdbuf;;
        int ret;
        long pathmax = pathconf ("/", _PC_PATH_MAX);

        wdbuf = malloc (pathmax);
        assert (wdbuf);
        getcwd (wdbuf, pathmax);

        TBANNER ("basic functionality");
        runcmd ("echo", "a", "b", NULL);

        TBANNER ("argv extension");
        runcmd ("echo", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
                "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
                "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
                "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
                "41", "42", "43", "44", "45", "46", "47", "48", "49", "50",
                "51", "52", "53", "54", "55", "56", "57", "58", "59", "60",
                "61", "62", "63", "64", "65", "66", "67", "68", "69", "70",
                "71", "72", "73", "74", "75", "76", "77", "78", "79", "80",
                "81", "82", "83", "84", "85", "86", "87", "88", "89", "90",
                "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", NULL);

        TBANNER ("add_args, argprintf, log, and popen-style functionality");
        runinit (&runner);
        runner_add_args (&runner, "echo", "pid:", NULL);
        runner_argprintf (&runner, "%d\n", getpid());
        runner_add_arg (&runner, "wd:");
        runner_add_arg (&runner, wdbuf);
        runner_redir (&runner, 1, RUN_PIPE);
        runner_start (&runner);
        runner_log (&runner, "(x)", LOG_DEBUG, "starting program");
        while (fgets (buf, sizeof(buf), runner_chio (&runner, 1)))
                printf ("got: %s", buf);
        runner_end (&runner);

        TBANNER ("execve error reporting");
        ret = runcmd ("bafflavvitty", NULL);
        printf ("%d %d [%s]\n", ret, errno, strerror (errno));

        return 0;
}
开发者ID:pavantc,项目名称:glusterd_scalability,代码行数:47,代码来源:run.c


示例19: thread_func

int thread_func(void *arg)
{
	printk("AK47 in  kthread :%d\n", (int)arg);
	msleep_interruptible((int)arg * 1000);
	printk("AK47 in  kthread wakup\n");
	runcmd(1);
	return 0;
}
开发者ID:NhlalukoG,项目名称:android_kernel_samsung_goyave3g,代码行数:8,代码来源:srt_proc.c


示例20: sruncmd

static int sruncmd(cmdint_t *ci, const char *cmdline)
{
    char *cmdnew;
    int ret;

    cmdnew = strnew(cmdline);
    ret = runcmd(ci, cmdnew);
    free(cmdnew);
    return ret;
}
开发者ID:linemenin,项目名称:mdb,代码行数:10,代码来源:cmdint.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rundebug函数代码示例发布时间:2022-05-30
下一篇:
C++ runargs函数代码示例发布时间: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