002_网上脚本执行请注意,慎重

Posted arun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了002_网上脚本执行请注意,慎重相关的知识,希望对你有一定的参考价值。

一、进坑过程如下

执行ansible遇到这种错误:
(1)
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /your/home/.virtualenvs/virtualenv_name/bin/python
  Reason: image not found
[1]    95221 trace trap  python

(2)于是从Google查解决方案。看到是之前同事写的,就没细看就执行了,执行关键内容如下
#https://gist.github.com/tevino/1a557a0c200d61d4e4fb

read -p "??  Press Enter if you are not sure (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "??  Removing old symbolic links......"
    find "$ENV_PATH" -type l -delete -print
    echo "??  Creating new symbolic links......"
    $SYSTEM_VIRTUALENV "$ENV_PATH"
    echo "??  Done!"
fi

(3)执行完就哭了,很多命令都找不到了,原因是删除了/usr/local/bin下的所有软连接

(4)粗糙的执行恢复:
cd /usr/local/bin
for i in `ls ../Cellar/*/*/bin`;do
    softlinksrc=`sudo find /usr/local/Cellar  -name $i|sed  ‘s#/usr/local#..#g‘`
    ln -s $softlinksrc .
done

二、总结

坑的连接如下:
#https://gist.github.com/tevino/1a557a0c200d61d4e4fb

其中有个叫laymonk的哥们明确说了这有坑了,所以以后Google和github出的内容一定要看完,谨记!!!

laymonk commented on Oct 7, 2016 ? 
I stumbled upon this, and just had to comment.

I imagine you reckon you are being helpful, but this a most dangerous thing to ask people to run. Running it could easily delete all links in /usr/local, which is the standard place homebrew installs pip (so, your $ENV_PATH will be /usr/local)

The simple fix involves just cd‘ing into the virtualenv, and deleting all the stale links to the upgraded python by running:
find . -type l -delete

.. and then re-installing your virtualenv:
mkvirtualenv venv-name or virtualenv venv-name

An unsuspecting user may not understand the implication of answering yes, and have all symlinks blown away from /usr/local .. I think you should take this down, or amend it. No offence intended.

  

 

以上是关于002_网上脚本执行请注意,慎重的主要内容,如果未能解决你的问题,请参考以下文章

在加载当前脚本时执行脚本

用python执行 js代码__来自脚本之家

nginx之自动日志切割--请注意这里不是脚本

002_解析go语言中的回调函数

错误记录在 Android Studio 的 Terminal 终端执行 gradlew 报错 ( 无法将“gradlew”项识别为 cmdlet函数脚本文件或可运行程序的名称。请检查名称 )

错误记录在 Android Studio 的 Terminal 终端执行 gradlew 报错 ( 无法将“gradlew”项识别为 cmdlet函数脚本文件或可运行程序的名称。请检查名称 )