{ "cells": [ { "cell_type": "code", "execution_count": 241, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os\n", "os.rename(path_ori, path_bak) \n", "os.makedirs(path_ori)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], "source": [ "import os.path\n", "os.path.isfile(\"/tmp\") \n", "os.path.exists(\"/tmp\")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['hostname', 'hosts', 'hosts.allow', 'hosts.deny', 'host.conf']" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import glob,os\n", "os.chdir(\"/etc\")\n", "os.getcwd()\n", "\n", "glob.glob('host*')" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "'/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py'" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import sys\n", "sys.argv[0]" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/etc\n" ] } ], "source": [ "print(os.path.dirname(os.path.realpath('__file__')))" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": true }, "outputs": [], "source": [ "f=open(path,'r',encoding='utf-8')\n", "content=f.read()\n", "f.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "exec(open(\"executable.sh\",encoding='utf-8').read())" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 1 }