Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. outspoken

    calculate percentage from variables

    ok, it is working now.. #!/usr/bin/python import os files = float(os.popen('ls ../files/ | wc -l').read().split()[0]) matches = float(os.popen('wc -l ../text/burn.roto_02').read().split()[0]) percent_matches=float(1.0*files/matches)*100 print percent_matches
  2. outspoken

    calculate percentage from variables

    that does work, thanks. i'm having another problem now, trying to get the right values from my os.system commands. they just return the 0 value instead of the actual numbers from the shell script. i'm looking at 'popen' and 'argv' to see if these will help in grabbing the stdout from those...
  3. outspoken

    calculate percentage from variables

    This is a pretty basic script, just wanting to grab some values from commandline and insert them into variables take those and calculate percentage. import os files = os.system('ls ../files/ | wc -l') matches = os.system('wc -l ../text/burn.roto_02 | awk \'{print $1}\'')...

Part and Inventory Search

Back
Top