Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94786

Re: How to re-write this bash script in Python?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'subject:Python': 0.05; 'from:addr:yahoo.co.uk': 0.05; 'correct.': 0.07; 'happen,': 0.07; 'subject:How': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'subject:script': 0.09; '"checking': 0.16; 'awk': 0.16; 'dfs': 0.16; 'echo': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'language': 0.19; 'lawrence': 0.22; 'skip:$ 20': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:_ 20': 0.26; '"no': 0.29; 'code': 0.30; 'skip:_ 10': 0.32; 'language.': 0.32; 'run': 0.33; 'url:python': 0.33; 'skip:_ 30': 0.33; 'traceback': 0.33; 'editor': 0.34; 'file': 0.34; 'done': 0.35; 'expected': 0.35; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'data': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'url:3': 0.60; 'your': 0.60; 'email addr:gmail.com': 0.62; 'back': 0.62; 'charset:windows-1252': 0.62; 'our': 0.64; 'here': 0.66; 'cut': 0.67; 'pythonistas,': 0.84; 'skip:/ 30': 0.84; 'subject:write': 0.84; 'subject:this': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: How to re-write this bash script in Python?
Date Thu, 30 Jul 2015 20:36:06 +0100
References <b07086dc-0946-4398-b621-23d564d54507@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-147-187-35.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
In-Reply-To <b07086dc-0946-4398-b621-23d564d54507@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Newsgroups comp.lang.python
Message-ID <mailman.1096.1438284995.3674.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438284995 news.xs4all.nl 2898 [2001:888:2000:d::a6]:43860
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94786

Show key headers only | View raw


On 30/07/2015 19:31, sutanu.das@gmail.com wrote:
> #!/bin/bash
>
> _maillist='pager@email.com'
> _hname=`hostname`
> _logdir=/hadoop/logs
> _dirlog=${_logdir}/directory_check.log
>
> _year=$(date -d "-5 hour" +%Y)
> _month=$(date -d "-5 hour" +%m)
> _day=$(date -d "-5 hour" +%d)
> _hour=$(date -d "-5 hour" +%H)
>
> _hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print $8}'`
>
> echo "Checking for HDFS directories:" > ${_dirlog}
> echo >> ${_dirlog}
>
> for _currdir in $_hdfsdir
> do
> hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog}
> done
>
> if [[ `grep -i "No such file or directory" ${_dirlog}` ]];
> then
> echo "Verify Flume is working for all  servers" | mailx -s "HDFS Hadoop Failure on Flume: ${_hname}" -a ${_dirlog} ${_maillist}
> fi
>

Read the documentation here https://docs.python.org/3/ and then run up 
your favourite editor and start typing.  When and if you hit problems 
come back with a snippet of code that shows the problem, what you 
expected to happen, what actually happened, and the full traceback if 
there is one.  Please use cut and paste to ensure that you get the data 
correct.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to re-write this bash script in Python? sutanu.das@gmail.com - 2015-07-30 11:31 -0700
  Re: How to re-write this bash script in Python? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-30 20:36 +0100
  Re: How to re-write this bash script in Python? random832@fastmail.us - 2015-07-30 16:17 -0400
  Re: How to re-write this bash script in Python? Chris Angelico <rosuav@gmail.com> - 2015-07-31 17:47 +1000
    Re: How to re-write this bash script in Python? Grant Edwards <invalid@invalid.invalid> - 2015-07-31 14:26 +0000
      Re: How to re-write this bash script in Python? Chris Angelico <rosuav@gmail.com> - 2015-08-01 00:53 +1000

csiph-web