Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Two methods of executing arbitrary commands in Runime.getRuntime () .exec & # 40

Shulou Source: shulou.com Published: 2022-06-01 04:05:53 10月06日 Update

It is often found that you need to pass parameters in an array to execute certain commands:

The reason is that when executing multiple arguments, spaces are treated as delimiters, so your command line is treated as multiple arguments:

Solution 1:

Use ${IFS}, for example:

Echo "a ${IFS} a ${IFS} a"

Solution 2:

Add the following instruction before the shell instruction you want to execute:

Sh-c $@ | sh. Echo

Tags: Commands methods parameters instructions delimiters causes multiple arrays modes times spaces Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information MariaDB Huawei Linux