无法运行 shel scrip 文件,权限被拒绝

无法运行 shel scrip 文件,权限被拒绝

我有 shell 脚本文件,基本上是安装 xilinx 工具的安装文件。文件的名称是 xsetup

在此处输入图片描述

我也这样做之后检查了它的权限

chmod  777 xsetup

在此处输入图片描述

实际上整个文件夹(其中有我的 xsetup)的权限是这样的:(我对每个文件都进行了读写访问,未在此屏幕截图中显示) 在此处输入图片描述

但是,当我尝试执行该文件时出现错误:

[root@sulaptop xilinx]# sh xsetup
xsetup: line 30: ./bin/lin/xsetup: Permission denied
[root@sulaptop xilinx]# bash xsetup 
xsetup: line 30: ./bin/lin/xsetup: Permission denied
[root@sulaptop xilinx]# 

当我已经以 root 身份登录时,为什么会出现此权限错误?以下是此脚本的内容:

#! /bin/sh
export PATH || exec /bin/sh "$0" $argv
# Get the path to this exec
setuploc=`dirname "$0"`

unset LANG
platform=`uname -s`

# run setup executable depending on different platform
if [ "$platform" = "Linux" ]
then
    machineType=`uname -m`; # Get the machine type
    if [ "$machineType" = "x86_64" ]
    then
    # 64 bit
        if [ -f "$setuploc/bin/lin64/xsetup" ]
        then
            "$setuploc/bin/lin64/xsetup" $*
        else
            if [ -f "$setuploc/bin/lin/xsetup" ]
            then
                "$setuploc/bin/lin/xsetup" $*
            else
                echo "Product is not supported on \"$platform\" platform."
            fi            
        fi
    else
        if [ -f "$setuploc/bin/lin/xsetup" ]
        then
            "$setuploc/bin/lin/xsetup" $*
        else
            echo "Product is not supported on \"$platform $machineType\" platform."
        fi
    fi
else
    echo "Un-supported platform: $platform"
fi

第 30 行是第一行

“$setuploc/bin/lin/xsetup”$*

从底部

平台

Fedora 17,64 位,因为我有一个带有 lm 的标志

grep lm /proc/cpuinfo:

 lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm 

答案1

您已更改 的权限/home/msz/xilinx/xsetup。但是,您的脚本调用的嵌套脚本是/home/msz/xilinx/bin/lin/xsetup。请修复正确文件的权限。

相关内容