"]}, "execution_count": 6, "metadata": {}, "output_type": "execute_result"}], "source": ["%remote_open"]}, {"cell_type": "markdown", "metadata": {}, "source": ["We try a simple command:"]}, {"cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "centrer_reduire.pig\n", "ConfLongDemo_JSI.txt\n", "diff_cluster\n", "dummy\n", "filter_example.pig\n", "filter_example.redirect.err\n", "filter_example.redirect.out\n", "init_random.pig\n", "iteration_complete.pig\n", "nb_obervations.pig\n", "pig_1436911046432.log\n", "pig_1436913856496.log\n", "pig_1436997076356.log\n", "post_traitement.pig\n", "pystream.pig\n", "pystream.py\n", "redirection.err\n", "redirection.out\n", "Skin_NonSkin.txt\n", "\n", "
"], "text/plain": [""]}, "execution_count": 7, "metadata": {}, "output_type": "execute_result"}], "source": ["%remote_cmd ls ."]}, {"cell_type": "markdown", "metadata": {}, "source": ["We then execute a python program on the remote machine, we first same the following code as a program:"]}, {"cell_type": "code", "execution_count": 7, "metadata": {"collapsed": true}, "outputs": [], "source": ["%%PYTHON exemple.py\n", "\n", "import sys\n", "print(\"path to python\", sys.executable)\n", "print(\"version \", sys.version_info)"]}, {"cell_type": "markdown", "metadata": {}, "source": ["The next command stores it as a file, uploads it to the remote machine and then executes it:"]}, {"cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "('path to python', '/usr/bin/python')\n", "('version ', (2, 6, 6, 'final', 0))\n", "\n", "
"], "text/plain": [""]}, "execution_count": 9, "metadata": {}, "output_type": "execute_result"}], "source": ["%remote_py exemple.py"]}, {"cell_type": "markdown", "metadata": {}, "source": ["We check it is different from the local version:"]}, {"cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [{"data": {"text/plain": ["('c:\\\\python34_x64\\\\python.exe',\n", " sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0))"]}, "execution_count": 10, "metadata": {}, "output_type": "execute_result"}], "source": ["import sys\n", "sys.executable, sys.version_info"]}, {"cell_type": "markdown", "metadata": {}, "source": ["If you want to use a different version of the interpreter, you can try (not available here):"]}, {"cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [{"data": {"text/html": ["ERR:
\n", "bash: anaconda3/bin/python3.4: No such file or directory\n", "\n", "
OUT:
\n", "\n", "
"], "text/plain": [""]}, "execution_count": 11, "metadata": {}, "output_type": "execute_result"}], "source": ["%remote_py -i=anaconda3/bin/python3.4 exemple.py"]}, {"cell_type": "markdown", "metadata": {}, "source": ["Sometimes, you need an interactive shell such as [Putty](http://www.putty.org/). Let's see how it works:"]}, {"cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": 12, "metadata": {}, "output_type": "execute_result"}], "source": ["%open_remote_shell"]}, {"cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "Last login: Fri Jan 30 11:37:57 2015 from aputeaux-551-1-113-111.w92-132.abo.wanadoo.fr\n", "[xavierdupre@ws09-en1.tl: ~]$ ls\n", "centrer_reduire.pig diff_cluster exemple.py filter_example.redirect.err init_random.pig nb_obervations.pig pig_1436913856496.log post_traitement.pig pystream.py redirection.out\n", "ConfLongDemo_JSI.txt dummy filter_example.pig filter_example.redirect.out iteration_complete.pig pig_1436911046432.log pig_1436997076356.log pystream.pig redirection.err Skin_NonSkin.txt\n", "[xavierdupre@ws09-en1.tl: ~]$ \n", "
\n", "\n", "\n", "\n"], "text/plain": [""]}, "execution_count": 13, "metadata": {}, "output_type": "execute_result"}], "source": ["%%shell_remote\n", "ls"]}, {"cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "python\n", "Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) \n", "[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2\n", "Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n", ">>> \n", "
\n", "\n", "\n", "\n"], "text/plain": [""]}, "execution_count": 14, "metadata": {}, "output_type": "execute_result"}], "source": ["%shell_remote python"]}, {"cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [{"data": {"text/html": ["\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", ">>> import sys\n", ">>> sys.executable\n", "'/usr/bin/python'\n", ">>> \n", "
\n", "\n", "\n", "\n"], "text/plain": [""]}, "execution_count": 15, "metadata": {}, "output_type": "execute_result"}], "source": ["%%shell_remote\n", "\n", "import sys\n", "sys.executable"]}, {"cell_type": "markdown", "metadata": {}, "source": ["To close the shell, we can just type:"]}, {"cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": 16, "metadata": {}, "output_type": "execute_result"}], "source": ["%close_remote_shell"]}, {"cell_type": "markdown", "metadata": {}, "source": ["And to close the connection:"]}, {"cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [{"data": {"text/plain": ["True"]}, "execution_count": 17, "metadata": {}, "output_type": "execute_result"}], "source": ["%remote_close"]}, {"cell_type": "markdown", "metadata": {}, "source": ["**END**"]}, {"cell_type": "code", "execution_count": 17, "metadata": {"collapsed": true}, "outputs": [], "source": []}], "metadata": {"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.1"}}, "nbformat": 4, "nbformat_minor": 2}