即使我输入了确切的路径,Unix Installer也找不到文件的路径 [英] Unix Installer can't find path to file even though I'm entering the exact path

查看:65
本文介绍了即使我输入了确切的路径,Unix Installer也找不到文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改现有的脚本来更新Flash,但安装程序将无法运行.

I'm trying to modify an existing script that updates Flash but the installer will not work.

我一直收到以下错误.

安装程序:错误指定的软件包路径无效:"/Volumes/Flash Player/Install Adob​​e Flash Player.app/Contents/MacOS/Adobe Flash Player安装管理器".

installer: Error the package path specified was invalid: '/Volumes/Flash Player/Install Adobe Flash Player.app/Contents/MacOS/Adobe Flash Player Install Manager'.

如果我将其修改为在文件路径末尾包含include.pkg,它也将不起作用.

It also does not work if I modify it to say include.pkg at the end of the filepath.

以下是脚本的其余部分:

Here is the rest of the script:

#!/bin/sh
# Script to download and install Flash Player.
# Only works on Intel systems.
#

dmgfile="flash.dmg"
volname="Flash"
logfile="FlashUpdateScript.log"
echo "Updating Flash player…"
# Are we running on Intel?
if [ '`/usr/bin/uname -p`'="i386" -o '`/usr/bin/uname -p`'="x86_64" ]; then
    # Get the latest version of Flash Player available from Adobe's About Flash page.
    latestver=`/usr/bin/curl -s http://www.adobe.com/software/flash/about/ | sed -n '/Safari/,/<\/tr/s/[^>]*>\([0-9].*\)<.*/\1/p'`
    # Get the version number of the currently-installed Flash Player, if any.
    if [ -e "/Library/Internet Plug-Ins/Flash Player.plugin" ]; then
    currentinstalledver=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/version CFBundleShortVersionString`
    else
    currentinstalledver="none"
    fi
    echo "Installed version:                 $currentinstalledver"
    echo "Currently last version to install: $latestver"
# Compare the two versions, if they are different of Flash is not present then download and install the new version.
if [ "${currentinstalledver}" != "${latestver}" ]; then
    echo "UPDATING…"
    /bin/echo "`date`: Current Flash version: ${currentinstalledver}" >> ${logfile}
    /bin/echo "`date`: Available Flash version: ${latestver}" >> ${logfile}
    /bin/echo "`date`: Downloading newer version." >> ${logfile}
    /usr/bin/curl http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_osx.dmg -o flash.dmg
    /bin/echo "`date`: Mounting installer disk image." >> ${logfile}
    /usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep Flash | awk '{print $1}') -quiet
    /usr/bin/hdiutil attach flash.dmg -nobrowse -quiet
    /bin/echo "`date`: Installing..." >> ${logfile}
    /usr/sbin/installer -pkg /Volumes/Flash\ Player/Install\ Adobe\ Flash\ Player.app/Contents/MacOS/Adobe\ Flash\ Player\ Install\ Manager -target /
    /bin/sleep 10
    /bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
    /usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep ${volname} | awk '{print $1}') -quiet
    /bin/sleep 10
    /bin/echo "`date`: Deleting disk image." >> ${logfile}
    /bin/rm ${dmgfile}
    newlyinstalledver=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/version CFBundleShortVersionString`
        if [ "${latestver}" = "${newlyinstalledver}" ]; then
            /bin/echo "`date`: SUCCESS: Flash has been updated to version ${newlyinstalledver}" >> ${logfile}
            echo "SUCCESS: Flash has been updated to version ${newlyinstalledver}"
        else
            /bin/echo "`date`: ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
            /bin/echo "--" >> ${logfile}
            echo "ERROR: Flash update unsuccessful, version remains at ${currentinstalledver}."
        fi
    # If Flash is up to date already, just log it and exit.       
    else
        /bin/echo "`date`: Flash is already up to date, running ${currentinstalledver}." >> ${logfile}
        /bin/echo "--" >> ${logfile}
        echo "Flash is already up to date, running ${currentinstalledver}."
    fi
else
/bin/echo "`date`: ERROR: This script is for Intel Macs only." >> ${logfile}
echo "ERROR: This script is for Intel Macs only."
fi

推荐答案

您需要确认路径的每个段都具有允许您写入该目录及其下的任何目录的权限.将以下脚本保存到PATH中的目录中(使用/usr/local/bin是适当的),或者将其保存到/tmp目录中,并在完整路径下使用它.

You need to confirm that each segment of the path has permissions that would allow you to write to that directory and any below it. Save the following script into a directory in your PATH (/usr/local/bin would be appropriate) OR save it into the /tmp dir and use it with a full path.

cat pathChecker.sh    
#!/bin/bash

path2chk="${@?usage:${0##*/} /path/to/check}"
if ! [[ -d "${path2chk}" ]] ; then
   echo "no directory access to ${path2chk}"
   echo "checking all elements anyway"
fi

echo "${path2chk}"\
| sed 's/\//\n/g' \
| while read pathElem ; do
    testPath="${testPath+${testPath}/}${pathElem}"
    #dbg echo "ls -ld \"$testPath\""
    ls -ld "$testPath"
done


chmod +x pathChecker.sh
pathChecker.sh '/Volumes/Flash Player/Install Adobe Flash Player.app/Contents/MacOS/Adobe Flash Player Install Manager'

应显示类似清单

drwxr-x-r-x ..... /Volumes
drwxr------ ..... /Volumes/Flash Player   # bzt!
. . . .

编辑,还可以在此处查看有关该问题的更一般的解释:

Edit Also see a more generic explanation of the problem here:

IHTH

这篇关于即使我输入了确切的路径,Unix Installer也找不到文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆