Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108281
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Jim Dodgen <jim@dodgen.us> |
| Newsgroups | comp.lang.python |
| Subject | redirecting stdout and stderr to /dev/null |
| Date | Sat, 7 May 2016 11:40:56 -0700 |
| Lines | 38 |
| Sender | jim.dodgen@gmail.com |
| Message-ID | <mailman.460.1462646798.32212.python-list@python.org> (permalink) |
| References | <CAJ2wgcp0HjygmdAw_Q1zJEs=BRWEuDnYRUzQPCcnZEbS0i3uSw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de /V0gAl3KuVObHF2qA5YrHArbA/I8hYJOgm142iSjUfhg== |
| Return-Path | <jim.dodgen@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'elegant': 0.07; "'w')": 0.09; '/dev/null': 0.09; 'ping': 0.09; 'stderr': 0.09; 'stdout': 0.09; 'sys.stderr': 0.09; 'sys.stdout': 0.09; 'python': 0.10; 'skip:f 30': 0.15; 'from:addr:jim': 0.16; 'googling': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:dev': 0.16; 'versed': 0.16; 'sender:addr:gmail.com': 0.18; 'bytes': 0.18; 'version.': 0.18; '"",': 0.22; 'import': 0.24; 'jim': 0.27; 'message-id:@mail.gmail.com': 0.27; '---': 0.28; 'fork': 0.29; 'loss,': 0.29; 'perl': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'compared': 0.30; 'run': 0.33; 'shorter': 0.33; 'skip:- 10': 0.34; 'languages': 0.34; 'received:google.com': 0.35; '8bit%:4': 0.35; 'quite': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'data.': 0.36; 'to:addr:python-list': 0.36; 'skip:& 10': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'things': 0.38; 'doing': 0.38; 'received:209': 0.38; 'skip:o 20': 0.38; 'skip:- 20': 0.39; 'test': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'skip:n 10': 0.62; 'here': 0.66; 'results': 0.66; 'cut': 0.67; 'skip:\xc2 10': 0.67; 'isolate': 0.84; 'received,': 0.84; 'redirecting': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to; bh=219PHNe/ARgRj1azAb6x1unrAnM8E/2my302sVb1ePU=; b=E03cwzATHWe27zxeZcEyhGesOmahKsAcfO9PaaIUxviZVJ4WqnFnkyvd4+ycgzOvDL YnphuFH5RJGzwYZoOEVV1OVYzpvOYq/FK33I7ovkbBNPeFmswRJgXMGrgcSgmUDDMOhG 9juUavnjEdMwwfI1dGr/eSpWT2tUVeGuzxxJAv4IpvcSrVINFcm8xmet5hJ/wCoWxR7C boZBo40bcGcASEiTFkVorLr6UMcRDis0kXAh7mA7j05TYWdxwbl9k8B/UrwWqthb90Uk BdPEoO9NnWFALUOHiW2e/gbf8bZQ1/l5AS/phM2QN7G0KeIra+FrfdXlr1U9UPWck8Un 0+4w== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=219PHNe/ARgRj1azAb6x1unrAnM8E/2my302sVb1ePU=; b=lCa79g/jLlPhvdiuWzyG0CVZwXeDr0xlQTyfJEeq3WMIc2rsjuExWKXbWhumQorEJS efliWbPlnChYfa+H20tu01zbvprIK0DxXtWRaz0XRQ3LpmwQEjdokp5rg3zMRros3iUX +LpLCJhFChHzSdD+Q62P2HwrFs5UjQhGEcqWh8BEio/egcDNTJL8iAYKmphEaun1NOtA dWfjpqXyi2XXA6YTP+rtUm/0zHpRz4JPg1AsjvUdJs9Zm/GxeMfTtRJ0Nm6czhdisdnQ Wa0WZxcLhg7/ptFsRV5dfMYw1AIJdS+VuihQH9KB9FmWmId3/S4VQ9iyuBtTTHrhyxPg gblA== |
| X-Gm-Message-State | AOPr4FUZANWQBuRVzfyrukz8sEC8I9GJk7ap5yf17AUZ/njYTCbUwqvRQRH3WBcmnxjBlJjRC/8b3PtwV80sDg== |
| X-Received | by 10.31.11.66 with SMTP id 63mr1919776vkl.10.1462646496049; Sat, 07 May 2016 11:41:36 -0700 (PDT) |
| X-Google-Sender-Auth | AR09ymw9hkIjiMlA-Pojs8aMaX8 |
| X-Mailman-Approved-At | Sat, 07 May 2016 14:46:37 -0400 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.22 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAJ2wgcp0HjygmdAw_Q1zJEs=BRWEuDnYRUzQPCcnZEbS0i3uSw@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:108281 |
Show key headers only | View raw
I'm new to python but well versed on other languages such as C and Perl
I'm have problems redirecting stdout and stderr to /dev/null in a
program that does a fork and exec. T found this method googling around and
it is
quite elegant compared to to the Perl version.
So to isolate things I made a much shorter test program and it still is not
redirecting. What am I doing wrong?
test program test.py
----------------- cut here -------------------
import sys
import os
f = open(os.devnull, 'w')
sys.stdout = f
sys.stderr = f
os.execl("/bin/ping", "", "-w", "20", "192.168.1.1");
------------------ cut here -------------------
results when run
root@dev:/home/jim# python test.py
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.36 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.00 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.01 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.16 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=1.02 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 1.002/1.114/1.361/0.136 ms
root@dev:/home/jim#
*Jim Dodgen*
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
redirecting stdout and stderr to /dev/null Jim Dodgen <jim@dodgen.us> - 2016-05-07 11:40 -0700
csiph-web