我自己进行了类似的测试:
$ strace -o /tmp/gnome.out -f gnome-terminal --working-directory=/var/log --tab -e "cat *.log ; echo hello"
$ grep --color=no execve /tmp/gnome.out
28561 execve("/usr/bin/gnome-terminal", ["gnome-terminal", "--working-directory=/var/log", "--tab", "-e", "cat *.log ; echo hello"], [/* 39 vars */]) = 0
28564 execve("/usr/lib/libvte9/gnome-pty-helper", ["gnome-pty-helper"], [/* 40 vars */]) = 0
28565 execve("/home/sarnold/bin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/usr/local/sbin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/usr/local/bin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/usr/sbin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/usr/bin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/sbin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */]) = -1 ENOENT (No such file or directory)
28565 execve("/bin/cat", ["cat", "*.log", ";", "echo", "hello"], [/* 40 vars */] <unfinished ...>
28565 <... execve resumed> ) = 0
这表明整个命令行正在传递给在字符串中找到的第一个可执行文件。(这是一种……独特的……执行内容的方式。)
我建议编写一个小的 shell 脚本,它完全符合您的要求,并gnome-terminal
-e
从命令行选项运行该 shell 脚本。像这样的东西:
~/bin/cp_first_output.sh
:
#!/bin/sh
cd /home/syntax_error/Desktop/uni_work/
./a.out './exec_me 500'
cp output.txt /home/syntax_error/FILES/first_output.txt
chmod 755
该文件,然后运行:
gnome-terminal --tab -e /home/syntax_error/bin/cp_first_output.sh