This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the_str = """Four score and seven years ago our fathers brought forth upon this \ | |
continent a new nation, conceived in liberty and dedicated to the \ | |
proposition that all men are created equal...""" | |
def word_wrap(the_str, chars_per_line): | |
''' | |
Returns formatted string based on number of characters per line | |
''' | |
iterator,space_pos,line_count = 0,0,0 | |
output = the_str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lex@server:~> python | |
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) | |
[GCC 4.4.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import django | |
>>> django.get_version() | |
'1.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
sudo: yes | |
vars: | |
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap | |
tasks: | |
- name: start tcpdump | |
command: /usr/sbin/tcpdump -i eth0 -s 0 -w /tmp/${cap_file} | |
async: 60 | |
poll: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fork | |
from time import sleep | |
# Fork the process | |
pid = fork() | |
if pid == 0: # We're in the child process | |
print "Child process up in this." | |
else: # We're in the parent process | |
print "Parent here, I just created child", pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> python fork.py | |
Parent here, I just created child 19478 | |
Child process up in this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fork, getppid | |
from time import sleep | |
pid = fork() | |
if pid == 0: # We're in the child process | |
print "Child process up in this." | |
print "My parent is", getppid() | |
else: | |
print "Parent here, I just created child", pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> python fork_ppid.py | |
Parent here, I just created child 19741 | |
Child process up in this. | |
My parent is 19740 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fork, getppid | |
from time import sleep | |
pid = fork() | |
if pid == 0: | |
print "I'm about to become an orphan!" | |
for _ in range(3): | |
sleep(1) | |
print "My parent is", getppid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> python fork_orphan.py | |
Parent here, I just created child 19683 | |
Child process up in this. | |
Right now, my parent is 19682 | |
> Right now, my parent is 1 | |
Right now, my parent is 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fork, getppid, wait | |
from sys import exit | |
from time import sleep | |
pid = fork() | |
if pid == 0: | |
print "Hope my parent doesn't forget me this time!" | |
for _ in range(3): | |
sleep(1) |
OlderNewer