Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
1631def1
Commit
1631def1
authored
Mar 20, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a new pyrasite-shell tool. Give it a pid, get a prompt.
parent
dc7a8469
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
docs/CLI.rst
docs/CLI.rst
+23
-0
pyrasite/tools/shell.py
pyrasite/tools/shell.py
+43
-0
setup.py
setup.py
+1
-0
No files found.
docs/CLI.rst
View file @
1631def1
...
...
@@ -20,4 +20,27 @@ pyrasite - A command-line interface for injecting code into running Python proce
For updates, visit https://github.com/lmacken/pyrasite
pyrasite-shell
--------------
You can easily open up a shell and execute commands in a running process using
the `pyrasite-shell`.
.. code-block:: bash
$ pyrasite-shell
Usage: pyrasite-shell <PID>
.. code-block:: bash
$ pyrasite-shell $(pgrep -f "python -v")
Pyrasite Shell 2.0beta7
Python 2.7.2 (default, Oct 27 2011, 01:40:22)
[GCC 4.6.1 20111003 (Red Hat 4.6.1-10)] on linux2
>>> print(x)
foo
>>> globals()['x'] = 'bar'
.. seealso:: :doc:`Payloads`
pyrasite/tools/shell.py
0 → 100644
View file @
1631def1
# This file is part of pyrasite.
#
# pyrasite is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyrasite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyrasite. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2012 Red Hat, Inc., Luke Macken <lmacken@redhat.com>
import
sys
import
pyrasite
def
shell
():
"""Open a Python shell in a running process"""
if
not
len
(
sys
.
argv
)
==
2
:
print
(
"Usage: pyrasite-shell <PID>"
)
sys
.
exit
(
1
)
pid
=
int
(
sys
.
argv
[
1
])
ipc
=
pyrasite
.
PyrasiteIPC
(
pid
)
ipc
.
connect
()
print
(
"pyrasite shell %s"
%
pyrasite
.
__version__
)
print
(
ipc
.
cmd
(
'import sys; print("Python " + sys.version + '
+
'" on " + sys.platform)'
))
try
:
while
True
:
print
(
ipc
.
cmd
(
raw_input
(
'>>> '
)))
except
:
pass
ipc
.
close
()
print
()
setup.py
View file @
1631def1
...
...
@@ -25,6 +25,7 @@ setup(name='pyrasite',
[console_scripts]
pyrasite = pyrasite.main:main
pyrasite-memory-viewer = pyrasite.tools.memory_viewer:main
pyrasite-shell = pyrasite.tools.shell:shell
"""
,
classifiers
=
[
'Development Status :: 4 - Beta'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment