update
This commit is contained in:
parent
2cad4fcd7f
commit
397187bedc
@ -253,6 +253,51 @@
|
||||
"result = subprocess.run([\"ls\", \"this_file_does_not_exist\"])\n",
|
||||
"print(result.returncode)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Obtaining the output of a system command"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"result = subprocess.run([\"host\", \"8.8.8.8\"], capture_output=True)\n",
|
||||
"\n",
|
||||
"result = subprocess.run([\"host\", \"8.8.8.8\"], capture_output=True)\n",
|
||||
"print(result.returncode)\n",
|
||||
"\n",
|
||||
"result = subprocess.run([\"host\", \"8.8.8.8\"], capture_output=True)\n",
|
||||
"print(result.stdout)\n",
|
||||
"\n",
|
||||
"result = subprocess.run([\"host\", \"8.8.8.8\"], capture_output=True)\n",
|
||||
"print(result.stdout.decode().split())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import subprocess\n",
|
||||
"result = subprocess.run([\"rm\", \"does_not_exist\"], capture_output=True)\n",
|
||||
"\n",
|
||||
"import subprocess\n",
|
||||
"result = subprocess.run([\"rm\", \"does_not_exist\"], capture_output=True)\n",
|
||||
"print(result.returncode)\n",
|
||||
"\n",
|
||||
"import subprocess\n",
|
||||
"result = subprocess.run([\"rm\", \"does_not_exist\"], capture_output=True)\n",
|
||||
"print(result.returncode)\n",
|
||||
"print(result.stdout)\n",
|
||||
"print(result.stderr)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
Reference in New Issue
Block a user