Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Python update already printed line. Post 302465096 by cbreiny on Thursday 21st of October 2010 03:56:27 PM
Old 10-21-2010
Python update already printed line.

Hi. I have a basic script in python that outputs like this..

Code:
$ ./test.py
1%
2%
3%
4%
5%
6%
7%
8%
9%
10%
...

But how can I make it so the output stays in 1 line?
So it would look something like this..
Code:
$ ./test.py
10%

..after the script got to 10%. So it just updated but printed on the same line.
I've seen this done before i just want to know how to do it. Any ideas?

Last edited by Scott; 10-21-2010 at 05:14 PM.. Reason: Please use code tags
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need the line to be printed in single line

Hi, I have my code like this v_site_eli=`sqlplus -s<<-EOsqlplus $SQL_USERNAME/$SQL_PASSWD WHENEVER SQLERROR EXIT SQL.SQLCODE WHENEVER OSERROR EXIT FAILURE SET TERM OFF SET HEAD OFF SET VERIFY OFF SET FEEDBACK OFF declare VARIABLE vn_return_sts varchaR2(6); begin SELECT... (1 Reply)
Discussion started by: mjkreddy
1 Replies

2. Programming

Parsing command line arguments in Python

Hi, I've a python script called aaa.py and passing an command line option " -a" to the script like, ./aaa.py -a & Inside the script if the -a option is given I do some operation if not something else. code looks like ./aaa.py -a . . if options.a ---some operation--- if not options.a... (1 Reply)
Discussion started by: testin
1 Replies

3. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

4. Red Hat

Python 2.6 on redhat 5 (update 8)

Hi, I would like to know wheather it is possible to install python 2.6 on RedHat Ent Linux 5 (update8) using rpms? I have checked by default Python 2.4 is installed. or wheather Redhat 6.0 needs to be installed for python 2.6? (1 Reply)
Discussion started by: manoj.solaris
1 Replies

5. Linux

Unable to access CentOS setup Network Configuration after attempting Python update

I attempted to update Python on my CentOS 5.6 VM and have encountered some issues after then. Initially yum wouldn't work, but I have resolved that. However, now I am unable to access the Network Configuration section under setup. When I do select this option I see this at the command line: ... (2 Replies)
Discussion started by: crmpicco
2 Replies

6. UNIX for Dummies Questions & Answers

How to get " printed on command line?

Hey, Is there a way I can print " in a command line? When I type "echo "set variable = disco"".... This actually prints echo set variable = disco but I would like to print it out as --- echo "set variable = disco" Thanks, Satya (4 Replies)
Discussion started by: Indra2011
4 Replies

7. Shell Programming and Scripting

Python update variable name in for loop

Hello all, Not sure if this question has been answered already. I have some xml Element variable as below: child19 = core_elem_dcache.find('stat') child20 = core_elem_dcache.find('stat') child21 = core_elem_dcache.find('stat') child22 = core_elem_dcache.find('stat'Next I... (2 Replies)
Discussion started by: Zam_1234
2 Replies

8. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies
BBHOSTGREP(1)						      General Commands Manual						     BBHOSTGREP(1)

NAME
bbhostgrep - pick out lines in bb-hosts SYNOPSIS
bbhostgrep --help bbhostgrep --version bbhostgrep [--noextras] [--test-untagged] [--bbdisp] [--bbnet] TAG [TAG...] DESCRIPTION
bbhostgrep(1) is for use by extension scripts that need to pick out the entries in a bb-hosts file that are relevant to the script. The utility accepts test names as parameters, and will then parse the bb-hosts file and print out the host entries that have at least one of the wanted tests specified. Tags may be given with a trailing asterisk '*', e.g. "bbhostgrep http*" is needed to find all http and https tags. The bbhostgrep utility supports the use of "include" directives inside the bb-hosts file, and will find matching tags in all included files. If the DOWNTIME or SLA tags are used in the bb-hosts(5) file, these are interpreted relative to the current time. bbhostgrep then outputs a "INSIDESLA" or "OUTSIDESLA" tag for easier use by scripts that want to check if the current time is inside or outside the expected uptime window. OPTIONS
--noextras Remove the "testip", "dialup", "INSIDESLA" and "OUTSIDESLA" tags from the output. --test-untagged When using the BBLOCATION environment variable to test only hosts on a particular network segment, bbtest-net will ignore hosts that do not have any "NET:x" tag. So only hosts that have a NET:$BBLOCATION tag will be tested. With this option, hosts with no NET: tag are included in the test, so that all hosts that either have a matching NET: tag, or no NET: tag at all are tested. --no-down[=TESTNAME] bbhostgrep will query the Xymon server for the current status of the "conn" test, and if TESTNAME is specified also for the current state of the specified test. If the status of the "conn" test for a host is non-green, or the status of the TESTNAME test is dis- abled, then this host is ignored and will not be included in the output. This can be used to ignore hosts that are down, or hosts where the custom test is disabled. --bbdisp Search the bb-hosts file following include statements as a BBDISPLAY server would. --bbnet Search the bb-hosts file following include statements as a BBNET server would. EXAMPLE
If your bb-hosts file looks like this 192.168.1.1 www.test.com # ftp telnet !oracle 192.168.1.2 db1.test.com # oracle 192.168.1.3 mail.test.com # smtp and you have a custom Xymon extension script that performs the "oracle" test, then running "bbhostgrep oracle" would yield 192.168.1.1 www.test.com # !oracle 192.168.1.2 db1.test.com # oracle so the script can quickly find the hosts that are of interest. Note that the reverse-test modifier - "!oracle" - is included in the output; this also applies to the other test modifiers defined by Xymon (the dialup and always-true modifiers). If your extension scripts use more than one tag, just list all of the interesting tags on the command line. bbhostgrep also supports the "NET:location" tag used by bbtest-net, so if your script performs network checks then it will see only the hosts that are relevant for the test location that the script currently executes on. USE IN EXTENSION SCRIPTS
To integrate bbhostgrep into an existing script, look for the line in the script that grep's in the $BBHOSTS file. Typically it will look somewhat like this: $GREP -i "^[0-9].*#.*TESTNAME" $BBHOSTS | ... code to handle test Instead of the grep, we will use bbhostgrep. It then becomes $BBHOME/bin/bbhostgrep TESTNAME | ... code to handle test which is simpler, less error-prone and more efficient. ENVIRONMENT VARIABLES
BBLOCATION If set, bbhostgrep outputs only lines from bb-hosts that have a matching NET:$BBLOCATION setting. BBHOSTS Filename for the Xymon bb-hosts(5) file. FILES
$BBHOSTS The Xymon bb-hosts file SEE ALSO
bb-hosts(5), hobbitserver.cfg(5) Xymon Version 4.2.3: 4 Feb 2009 BBHOSTGREP(1)
All times are GMT -4. The time now is 09:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy