Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用cat时权限被拒绝-即使作为根用户?_Python_Bash_Ubuntu_Cat - Fatal编程技术网

Python 使用cat时权限被拒绝-即使作为根用户?

Python 使用cat时权限被拒绝-即使作为根用户?,python,bash,ubuntu,cat,Python,Bash,Ubuntu,Cat,我怎么可能使用以下命令被拒绝许可?我正在使用Python2.7和Ubuntu12.04 下面是我的mapper.py文件 import sys import json for line in sys.stdin: line = json.loads(line) key = "%s:%s" % (line['user_key'],line['item_key']) value = 1 sys.stdout.write('%s\t%s\n' % (key,value

我怎么可能使用以下命令被拒绝许可?我正在使用Python2.7和Ubuntu12.04

下面是我的mapper.py文件

import sys
import json

for line in sys.stdin:
    line = json.loads(line)
    key = "%s:%s" % (line['user_key'],line['item_key'])
    value = 1
    sys.stdout.write('%s\t%s\n' % (key,value))
下面是我的数据文件

{"action": "show", "user_key": "heythat:htuser:32", "utc": 1368339334.568242, "id": "d518b7c5-a180-439b-8036-2bb40ca080cd", "item_key": "heythat:htitem:1000"}
{"action": "click", "user_key": "heythat:htuser:32", "utc": 1368339334.573988, "id": "cc8c35ec-9e67-4ef8-a189-6116c7d0336a", "item_key": "heythat:htitem:1001"}
{"action": "click", "user_key": "heythat:htuser:32", "utc": 1368339334.575226, "id": "6c457f9a-afc2-4b61-be2f-d4ea2863aa69", "item_key": "heythat:htitem:1002"}
{"action": "show", "user_key": "heythat:htuser:32", "utc": 1368339334.575315, "id": "e0b08c30-459b-4f77-b9a4-05939457ab99", "item_key": "heythat:htitem:1000"}
{"action": "click", "user_key": "heythat:htuser:32", "utc": 1368339334.57538, "id": "90084ea2-75c6-4b8a-bc22-9d9f2da1c0de", "item_key": "heythat:htitem:1002"}
{"action": "show", "user_key": "heythat:htuser:32", "utc": 1368339334.57538, "id": "2f76a861-2b66-430a-b70d-2af6e1b9f365", "item_key": "heythat:htitem:1001"}
{"action": "show", "user_key": "heythat:htuser:32", "utc": 1368339334.57538, "id": "282eec8a-7f6d-4ad3-917a-aae049062d87", "item_key": "heythat:htitem:1002"}
{"action": "show", "user_key": "heythat:htuser:32", "utc": 1368339334.575447, "id": "bc48a6bc-f8f8-420e-9b80-0bd0c2bbde0d", "item_key": "heythat:htitem:1000"}
{"action": "show", "user_key": "that:htuser:32", "utc": 1368339334.575513, "id": "14b49763-e2fe-4beb-bff6-f4b34b3d2ef3", "item_key": "that:htitem:1001"}
{"action": "show", "user_key": "that:htuser:32", "utc": 1368339334.575596, "id": "983cbcf3-4375-4b3b-86ed-a8fbc86ff4b3", "item_key": "that:htitem:1002"}
下面是我的错误

 cat /home/ubuntu/workspace/logging/data.txt | /home/ubuntu/workspace/logging/mapper.py
bash: /home/ubuntu/workspace/logging/mapper.py: Permission denied

您的
mapper.py
文件需要是可执行的(在某些可执行分区上),因此
chmod a+x mapper.py

基础系统调用在以下情况下失败:

   EACCES Execute permission is denied for the file or a script or ELF
          interpreter.

   EACCES The file system is mounted noexec.

您的
mapper.py
文件需要是可执行的(在某些可执行分区上),因此
chmod a+x mapper.py

基础系统调用在以下情况下失败:

   EACCES Execute permission is denied for the file or a script or ELF
          interpreter.

   EACCES The file system is mounted noexec.

您可以向命令中添加“python”,如下所示

cat /home/ubuntu/workspace/logging/data.txt | python /home/ubuntu/workspace/logging/mapper.py

您可以向命令中添加“python”,如下所示

cat /home/ubuntu/workspace/logging/data.txt | python /home/ubuntu/workspace/logging/mapper.py