创建一个调用另一个可执行文件 [英] Create an executable that calls another executable?

查看:91
本文介绍了创建一个调用另一个可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 这是否已经完成?

    li>
  2. 使用 system(myAp param)对于每次调用都是错误的(当然有不同的 param



  3. 我在Linux-Ubuntu上使用kdevelop。



    从您的意见中,我明白了,而不是:

      system(path / to / just_testing p1 P2\" ); 

    我将使用:

      execl(path / to / just_testing,path / to / just_testing,p1,p2,(char *)0); 

    是真的吗?你说 execl 系统更安全,最好使用?


    在非专业领域,使用 system()是完全可以接受的,但要注意的是,人们会一直告诉你这是错误的。这没有错,这是一种解决问题的方法,不会太复杂。这有点马虎,是的,但肯定仍然是可用的(如果便携性稍差)选项。由 system()调用返回的数据将是您调用的应用程序的返回值。基于你的文章中有限的信息,我认为这就是你真正想知道的。


    I want to make a small application that runs another application multiple times for different input parameters.

    1. Is this already done?
    2. Is it wrong to use system("myAp param"), for each call (of course with different param value)?

    I am using kdevelop on Linux-Ubuntu.

    From your comments, I understand that instead of:

    system("path/to/just_testing p1 p2");
    

    I shall use:

    execl("path/to/just_testing", "path/to/just_testing", "p1", "p2", (char *) 0);
    

    Is it true? You are saying that execl is safer than system and it is better to use?

    解决方案

    In the non-professional field, using system() is perfectly acceptable, but be warned, people will always tell you that it's "wrong." It's not wrong, it's a way of solving your problem without getting too complicated. It's a bit sloppy, yes, but certainly is still a usable (if a bit less portable) option. The data returned by the system() call will be the return value of the application you're calling. Based on the limited information in your post, I assume that's all you're really wanting to know.

    这篇关于创建一个调用另一个可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆