shell - Python下exec_command('cd /;ll')为什么不执行呢?大神赐教啊
伊谢尔伦
伊谢尔伦 2017-04-18 09:41:40
0
1
570

Python下执行stdin,stdout,stderr = work.exec_command('cd /;ls -l')可以正常执行,
但是stdin,stdout,stderr = work.exec_command('cd /;ll')就无法执行


>>> stdin,stdout,stderr = work.exec_command('cd /;ls -l')
>>> print stdout.read()
total 110
dr-xr-xr-x.   2 root root  4096 Jul 10  2015 bin
dr-xr-xr-x.   5 root root  1024 Sep 22 12:52 boot
drwxr-xr-x.  18 root root  3900 Sep 25 16:01 dev
drwxr-xr-x. 102 root root 12288 Sep 27 03:26 etc
drwxr-xr-x.   2 root root  4096 Sep 27 11:08 file
drwxr-xr-x.   4 root root  4096 Jul 10  2015 home
drwxrwxrwx.   4 root root  4096 Sep 26 19:54 i2test
-rw-r--r--.   1 root root  3874 Sep 27 11:18 iawork_2016-09-27.log
dr-xr-xr-x.  10 root root  4096 Jul 10  2015 lib
dr-xr-xr-x.   9 root root 12288 Jul 10  2015 lib64
drwx------.   2 root root 16384 Jul  4  2015 lost+found
drwxr-xr-x.   2 root root  4096 Sep 23  2011 media
drwxr-xr-x.   3 root root  4096 Jul  4  2015 mnt
drwxr-xr-x.   5 root root  4096 Jul 10  2015 opt
dr-xr-xr-x. 151 root root     0 Sep 25 16:00 proc
dr-xr-x---.  24 root root  4096 Sep 26 09:24 root
dr-xr-xr-x.   2 root root 12288 Jul 10  2015 sbin
drwxr-xr-x.   7 root root     0 Sep 25 16:00 selinux
drwxr-xr-x.   2 root root  4096 Sep 23  2011 srv
drwxr-xr-x.  13 root root     0 Sep 25 16:00 sys
drwxrwxrwt.  20 root root  4096 Sep 27 09:43 tmp
drwxr-xr-x.  13 root root  4096 Jul  4  2015 usr
drwxr-xr-x.  21 root root  4096 Jul  4  2015 var

>>> stdin,stdout,stderr = work.exec_command('cd /;ll')
>>> print stdout.read()

>>>

这是什么原因导致的呢,请大神赐教哈

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
左手右手慢动作
work.exec_command('source ~/.bashrc; cd /;ll')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template