运行 命令行包含重定向 >> 内部虚拟机
run command line contains redirection >> inside Guest VM
至 运行 ls -l /home
例如,在名为 myvm
的来宾 VM 中,我们可以 运行 在主机上:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/ls --wait-stdout --wait-stderr -- ls/arg0 -l /home
现在,如果我们尝试 运行 此命令 echo "this is new line " >> /home/u1/sample.txt
使用相同的方法:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/echo --wait-stdout --wait-stderr -- echo/arg0 "this is new line " >> /home/u1/sample.txt
--> 我有:
bash: /home/u1/sample.txt : No such file or .
我添加引号:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/echo --wait-stdout --wait-stderr -- echo/arg0 '"this is new line " >> /home/u1/sample.txt'
--> Guest VM 中没有任何更改,我的意思是 /home/u1/sample.txt
.
有什么想法吗?知道我使用 VirtualBox 5.0.0
因为 :
command > redirect
类似于:
/bin/sh -c "command > redirect"
然后:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/sh --wait-stdout --wait-stderr -- sh/arg0 -c "echo this is new line >> /home/u1/sample.txt"
至 运行 ls -l /home
例如,在名为 myvm
的来宾 VM 中,我们可以 运行 在主机上:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/ls --wait-stdout --wait-stderr -- ls/arg0 -l /home
现在,如果我们尝试 运行 此命令 echo "this is new line " >> /home/u1/sample.txt
使用相同的方法:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/echo --wait-stdout --wait-stderr -- echo/arg0 "this is new line " >> /home/u1/sample.txt
--> 我有:
bash: /home/u1/sample.txt : No such file or .
我添加引号:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/echo --wait-stdout --wait-stderr -- echo/arg0 '"this is new line " >> /home/u1/sample.txt'
--> Guest VM 中没有任何更改,我的意思是 /home/u1/sample.txt
.
有什么想法吗?知道我使用 VirtualBox 5.0.0
因为 :
command > redirect
类似于:
/bin/sh -c "command > redirect"
然后:
vboxmanage --nologo guestcontrol myvm --username root --password xxxx run --exe /bin/sh --wait-stdout --wait-stderr -- sh/arg0 -c "echo this is new line >> /home/u1/sample.txt"