将命令行参数传递给应用程序

Day*_*ite 1 perl command

我想从Perl脚本执行一个应用程序.

Perl脚本使用变量作为参数调用应用程序,其值是一个长字符串,其中包含大量空格.

应用程序将这些解释为单独的字符串,但我想将它们全部作为一个字符串.

这是Perl脚本中的代码:

$command = "Hello world here i come. Hope this works"
Run Code Online (Sandbox Code Playgroud)

当Perl脚本尝试调用应用程序时

./a.out $command
Run Code Online (Sandbox Code Playgroud)

在我试图访问的应用程序中argv[1],我只得到字符串Hello.argv[2]包含world但我想argv[1]包含其中包含的完整字符串$command.我该怎么做?

jus*_*ime 5

使用exec的多参数形式

exec "./a.out", $command
Run Code Online (Sandbox Code Playgroud)

通过这种方式,shell不会涉及到