Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ervin =?utf-8?Q?Heged=C3=BCs?= Newsgroups: comp.lang.python Subject: Re: Testing whether the VPN is running? Date: Thu, 18 Feb 2016 10:45:31 +0100 Lines: 26 Message-ID: References: <2cfgpcxdg2.ln2@news.ducksburg.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de OUAbb6vpntE9yGS1Hn/HMAl/4PZVdo40U+K5REJAgdxg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'utf-8': 0.07; 'cc:addr:python-list': 0.09; 'python': 0.10; 'output': 0.13; 'section.': 0.15; 'thu,': 0.15; '2016': 0.16; 'adam': 0.16; 'command,': 0.16; 'modul': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'task:': 0.16; 'vpn': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'keywords,': 0.22; 'cc:no real name:2**0': 0.22; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'not.': 0.27; 'way?': 0.29; "i'd": 0.31; 'run': 0.33; 'url:python': 0.33; 'running': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'received:74.125.82': 0.35; 'there': 0.36; 'url:org': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'test': 0.39; 'subject:the': 0.39; "didn't": 0.39; 'subject:Testing': 0.84; 'received:hu': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=kV0ZK3i0Gt0Sp6nWwGF65i+hUQNv8KenGY9Wfx1QEuc=; b=YRfNu0WO7V6dL63SGaU96eAqvpc5oo5/F+X3B9ffeVWhJ5dFf18jjojUuTdY9Df3PK gmqgESpxLNWHdNQUEG+JmCKJRs5PPJVX/3rfx4nX96aimHHVPZ4KyGtxc+8rBWMtT8jL +dl8xrJkojIbrD19e0dqAd/qghGqHPHdrZZvVM0oZZlbdBbWnsxtBCd8LeyMXtK+Qoqx udKS0dG/gOAeGFPFj9oCHMaRXq3XgciA6iK9BmHpHXlmaWuUlx7+2VPu9+rpR4TmPdRF ThaZKBUqsmZuU9vMxKgAaBvywO398iP9wyNEybNeYtIxC34j2fJmS+0HALAeZxloRwcb lFTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=kV0ZK3i0Gt0Sp6nWwGF65i+hUQNv8KenGY9Wfx1QEuc=; b=aKadUDqy94N4H9FRXMK6uq5El+gS9KMYaSB1Gpt9dqrxy7XL3PjA2X/GpimSebXpDM 94wZP9YjxnSDEv2SEmQQZbJfON6v4lk6Wq/bpbl9D07DGcyyHQjCNREDnnduA1JMBuqV TSs2nymM/FYNPLeo/YS+ctQrrdQwUPNa7APvdqaKMpykxFoRhhnkRjXJenNeLX4uswwb fQ2+bAAvOwfYHvBMqb+Ilquorc6PqJVkAxhFT4xLGv/4gjXc5gw4fVz+l7qNKpFsZlao aN4LIPdGZxtv9v4E4jMcAGNMOq5V9DOAwwxafFJIIdH2tK2aUb/UOxNclT6ZlHhFY3X0 Cutw== X-Gm-Message-State: AG10YOShFdTUi+Zzf0vn09Mxyv+h2Lx+go5452LqiF/8PcZ22ALYonTsjAYTY9c3TvfaZQ== X-Received: by 10.28.148.130 with SMTP id w124mr2339346wmd.71.1455788733993; Thu, 18 Feb 2016 01:45:33 -0800 (PST) Content-Disposition: inline In-Reply-To: <2cfgpcxdg2.ln2@news.ducksburg.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103098 Hi Adam, On Thu, Feb 18, 2016 at 09:26:58AM +0000, Adam Funk wrote: > I'd like to test (inside a python 3 program) whether the VPN is > running or not. The only thing I can think of so far is to use > subprocess to run the 'ifconfig' command, then check its output for > 'tun0'. Is there a better way? you didn't wrote, which system (OS) you want to use - based on the "ifconfig" and "tun0" keywords, possible that's a Linux. I think that the psutil modul could be better for you for this task: https://pypi.python.org/pypi/psutil/ and see the "Network" section. Regards, a. -- I � UTF-8