Posts
 
Reputation
Joined
Last Seen
Ranked #434
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
100% Quality Score
Upvotes Received
10
Posts with Upvotes
10
Upvoting Members
7
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
4 Commented Posts
0 Endorsements
Ranked #344
~110.51K People Reached
Favorite Tags

123 Posted Topics

Member Avatar for a1eio

[QUOTE=a1eio;332281]yea, i forgot to mention, i'm trying to do this on a windows machine. the os.popen idea did occur to me, but then i got stuck again.. :p i don't know the dos command for opening the cd drive. thanks a1eio[/QUOTE] if you have pygame, you can use its inbuilt …

Member Avatar for Mahmoud_16
0
5K
Member Avatar for chris99

[QUOTE=Ene Uran;249919]If anyone figures out a different way to sort by word length....[/QUOTE] [code] >>> list1 = ['Herring','used','to','be','abundant','in','the','Atlantic','Ocean','then','herring','got','overfished'] >>> lengthlist = map(len,list1) >>> lengthlist [7, 4, 2, 2, 8, 2, 3, 8, 5, 4, 7, 3, 10] >>> all = zip(lengthlist,list1) >>> all [(7, 'Herring'), (4, 'used'), (2, 'to'), (2, …

Member Avatar for farmwife
0
6K
Member Avatar for Lardmeister

[QUOTE=Lardmeister;334753]When I run: [code]dec = 255 print hex(dec) [/code]I get 0xff, but I like to get just 'ff'[/QUOTE] '0x' always appears in front, so if you want to use hex() and get rid of 0x, use hex(255)[2:]

Member Avatar for bumsfeld
0
5K
Member Avatar for chris99

[QUOTE=chris99;253120] [code] def prompt_rea(): global gold .... .... [/code] Can you see the problem?[/QUOTE] if you want to use gold as global, u might like to put "global gold" inside prompt_rea()

Member Avatar for Jacklittle01
0
1K
Member Avatar for sneekula

[QUOTE=sneekula;317313]I need to read in a text file, replace selected words and write the changed text back out to a file. Is there an easy way with Python?[/QUOTE] there are several ways. 1) reading with for loop [code] o = open("output","a") #open for append for line in open("file"): line = …

Member Avatar for halamas
0
20K
Member Avatar for sneekula

[QUOTE=sneekula;318529]Is there a reliable way to 'pluralize' english words with Python?[/QUOTE] there are some cookbook recipe in ASPN you can refer to. [URL="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82102"]here[/URL]. they may not be wat you want, but at least will give you a head start

Member Avatar for TrustyTony
0
6K
Member Avatar for playonlcd

you do it systematically using the same way to read single level dict [code]d={'AAA': {'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB': {'BBB1':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB2':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB3':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}}} for i,j in d.iteritems(): for m,n in j.iteritems(): print m,n [/code] …

Member Avatar for playonlcd
0
492
Member Avatar for back2arie

things can be that easy. [code] $string = "<TEXT> Some text Another text </TEXT>"; @s=split /<\/TEXT>/, $string; $s[0] =~ s/.*<TEXT>// ; print $s[0]; [/code]

Member Avatar for k_manimuthu
0
144
Member Avatar for kbalamuk

>>> a = 'nf+nfpermult+nf' >>> a=a.split("+") >>> for n,i in enumerate( a ): ... if i == "nf": a[n]="1.0" ... >>> print '+'.join(a) 1.0+nfpermult+1.0

Member Avatar for vegaseat
-1
6K
Member Avatar for rehber344

you are using the "wrong" approach to reading a file. use a for loop [CODE] f=open("file") for line in f: print "do something with ",line f.close()[/CODE]

Member Avatar for woooee
0
188
Member Avatar for masterinex

use a html parser for this job, such as BeautifulSoup. If you don't want to, then another way is to read the whole html, split on "</div>", go through each element in the list, check for "<div class="info-content">", if found, replace it will null. You will get your string

Member Avatar for vegaseat
0
236
Member Avatar for masterinex

no need to use regex 1) split on "</a>" 2) go through list, check of List?ratings. 3) get index of ">, 4) print [code] >>> string = '''<a href="/ratings_explained">weighted average</a> vote of <a href="/List?ratings=7">7.2</a> / 10</p><p>''' >>> for i in string.split("</a>"): ... if "List?ratings" in i: ... print i[ i.rindex('">')+2 …

Member Avatar for ghostdog74
0
102
Member Avatar for dimitar.dk

it depends on what errors you are looking for. If there are 1000s of errors, are you going to send all 1000 ++ errors to your email?? you have to describe clearly your specs.

Member Avatar for JeoSaurus
0
141
Member Avatar for k1w1dad

you can use splitext from os module [code] import os,shutil def renamer(target) : os.chdir(target) for filename in os.listdir('.') : print filename newfilename = os.path.splitext(filename)[0] print newfilename os.rename(filename, newfilename) print "Renamed " + filename + " to " + new_filename shutil.copy("copyme","newcopyme" [/code]

Member Avatar for Gribouillis
0
206
Member Avatar for darnoc

use awk [code] awk '/default = ALL/{ print "default = DES-168" print "default = RC2-128" print "default = RC4-128" print "#"$0 next}1' file [/code]

Member Avatar for darnoc
0
180
Member Avatar for babno

[code] # perl -ne 'print if !(/\[SectionOne\]/ .. /\[SectionTWO\]/); ' file Entry1=19 Entry2=hello there [/code] use module like Config::IniFiles is still the best.

Member Avatar for babno
0
2K
Member Avatar for qaokpl

you can learn the basics of Perl first. One of the many good sources is straight from the doc. type perldoc perl for more info. otherwise, you can always view online Perl doc with your browser. After you are proficient with it, you can play with web frameworks, such as …

Member Avatar for ghostdog74
0
173
Member Avatar for Debangana

i think you shouldn't need to worry too much on whether its the correct directory because you would have set it properly when configuring your FTP server.

Member Avatar for ghostdog74
0
119
Member Avatar for metaface

if you have Perl, you can use the MP3::Tag module. eg [code] use MP3::Tag; # set filename of MP3 track my $filename = "test.mp3"; # create new MP3-Tag object my $mp3 = MP3::Tag->new($filename); # get tag information my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo(); print "$title, $track, …

Member Avatar for ghostdog74
0
510
Member Avatar for Bhoot

regular expressions are usually not needed for string manipulations. [code] # echo "abcdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}' # echo "abbdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}' ok [/code]

Member Avatar for ghostdog74
0
298
Member Avatar for snahata
Member Avatar for ghostdog74
0
399
Member Avatar for pinder

[QUOTE=pinder;343621]Hi, I'm trying to copy a file in python, I have imported the shutil module My problem is that I want to copy file in a directory beginning with a certain name. Example I have 5 file in the fodler but i want to copy all the one tat begin …

Member Avatar for nrupparikh
0
130
Member Avatar for rusman
Member Avatar for phynias

[code] awk 'BEGIN{FS="[]].[[]|[[]|[]]"} { gsub(/id|\"/,"",$13) split($3,a,"/") gsub("tag","",$16) print $13,a[1],$7,$16 }' file [/code]

Member Avatar for manik007
0
129
Member Avatar for knish

without glob module, just search for it [code] import os os.chdir("/somewhere") for files in os.listdir("."): if not "_ab" in files: print files [/code]

Member Avatar for ghostdog74
0
141
Member Avatar for bimaljr

[QUOTE=bimaljr;689099]Hi, I just need to know a simple command to bulk renaming. I have hundreds of .DEB files. I want to remove [B]4%3a[/B] from all file names. [B]example :[/B] [I]old name :[/I] ark-kde4_4%3a4.0.3-0ubuntu4_i386.deb [I]new name :[/I] ark-kde4_4.0.3-0ubuntu4_i386.deb I know there is a "rename" command but I don't know it's use. …

Member Avatar for bimaljr
0
189
Member Avatar for yair7190

[QUOTE=Gromit;686845]I poked at your original script and made some syntax changes to your "if" statement. I think it does what you want now. I think you have to use brackets when doing a comparison like this: [code] $ cat daniweb.sh #!/usr/bin/bash memUsage=$(ps -C bash -o pid=,size|awk '{SUM += $2} END …

Member Avatar for ghostdog74
0
120
Member Avatar for yair7190
Member Avatar for ghostdog74
0
151
Member Avatar for picass0

Look at the bash guide [URL="http://tldp.org/LDP/abs/html/testbranch.html"]here[/URL]. It has examples on checking for upper case.

Member Avatar for ghostdog74
0
2K
Member Avatar for picass0
Member Avatar for rusman

[code] awk 'BEGIN{FS="[: ]"} /Name/{ name=$3 } /Active/ && /Yes/{ cmd = "mailx -s \""name " is active\" body root" system(cmd) } ' file [/code]

Member Avatar for eggi
0
159
Member Avatar for krammer

do it using awk's srand() and rand(). [code] awk 'BEGIN{ srand() num=int(rand() * 10) + 1 } NR==num' file [/code]

Member Avatar for ghostdog74
0
203
Member Avatar for maxmave

if TEST2 is the second field and no where else and you want to replace only that second field, [code] awk 'NR==4{$2="DEV"}1' file [/code]

Member Avatar for ghostdog74
0
351
Member Avatar for k2k

[QUOTE=k2k;620065]can anyone tell me how I can print the first or the last character from a sh file ? i have done research on regular expression and the grep... i couldn't find any cmd that i can use to achieve this task. Thanks a lot.[/QUOTE] [code] awk 'BEGIN{FS=""}NR==1{print $1}{l=$NF}END{print l}' …

Member Avatar for ghostdog74
0
142
Member Avatar for Anilbrp

[QUOTE=Anilbrp]Hi all, I am new to this perl script. I want to open notepad.exe in perl script in the foreground., i.e if I give the command as system ("c:\\windows\\notepad.exe") , notepad should appear in the foreground. (should not run as a background process). I am using Apache server on windows. …

Member Avatar for samarudge
0
2K
Member Avatar for wandie

[QUOTE=wandie;358984]Could someone please help. I would like to sort a multidimensional array. But to sort it out by one key which appears in all array for example. [code] total=[[serial,'john'],[[serial,'james']] [/code] all the records i have all in arrays they contain a "serial" i would like sort by serial. I have …

Member Avatar for PlagTag
0
259
Member Avatar for skelly16

[QUOTE=skelly16;584443]Ok the issue i have worked out is when there seems to be a space on the new line on the file. i.e. cat apps/tech/testruniquefailures <space is here> batchjob1 batchjob2 How do i make sure the above file does not have a space on the top of it.[/QUOTE] don't use …

Member Avatar for eggi
0
163
Member Avatar for emile123
Member Avatar for cyberman111
Member Avatar for Impact4ever
0
153
Member Avatar for paurik

[QUOTE=paurik;580658]Hi i m devloping one intratnet appllication for that i want some hardwre information like memory type,memory bank, BIOS information. I have no rights login as super user. if anybody has any idea for that plese give me reply.[/QUOTE] if you are really developing an intranet application, then ask the …

Member Avatar for eggi
0
182
Member Avatar for ahjiefreak

[code] awk '$NF <=3 {a[NR]=$NF;c[a[NR]]=$0} END{ n=asort(a,b) print c[b[n]] }' file [/code] output: [code] # ./test.sh 18 126 2833 30 0.010479 2.842 [/code]

Member Avatar for eggi
0
897
Member Avatar for mooglor

use the -v option of awk to pass in shell variables so that you don't have to get too confused between shell and awk variables. eg [code] awk -v archive="$ARCHIVE" ' { print archive # etc code } [/code] also you do not need to use ls , grep and …

Member Avatar for ghostdog74
0
136
Member Avatar for skelly16
Member Avatar for eggi
0
781
Member Avatar for xthexonex

simply assign to a variable first [code] cmd = "useradd -G " var1 " -g " var2 " -m -s " $1 " -u " $2 " -K PASS_MIN_LEN=4 -K PASS_MAX_LEN=7 -p \047*\047" "usrname" print cmd # to see if your cmd is correct system(cmd) [/code]

Member Avatar for ghostdog74
0
106
Member Avatar for alex05

[QUOTE=alex05;163184]I have to write a script called trying. The script takes a full path (like /users4/st/jdoe/prog.c) as an argument and displays the path and the file name. For /users4/st/jdoe/prog.c, the path is /users4/st/jdoe and the file name is prog.c. I know that I can use grep for it, but it's …

Member Avatar for msr_viz
0
248
Member Avatar for rhnaeco
Member Avatar for lookof2day
Member Avatar for ghostdog74
0
134
Member Avatar for binnie

[QUOTE=binnie;509555]I would like to ask for the looping statements and conditional statements syntax and some samples for me to easily understand... And also, How can I edit numbers to have its decimal points like float and double in other programming language. I'm really noobie with Linux so can someone please …

Member Avatar for binnie
0
133
Member Avatar for n2201

[QUOTE=eggi;457585]#!/bin/ksh cat inputfile.txt|while read v w x do if [ -e $x ] then num_lines=`wc -l $x|sed -e 's/ *//' -e 's/ .*$//'` time_stamp=`ls -l $x|awk '{print $6 "_" $7 "_" $8}'` echo "$v $w $x $num_lines $time_stamp" fi done [/QUOTE] no need for cat [code] while read .... do …

Member Avatar for eggi
0
109
Member Avatar for jch

[code] find /path -type f -name "status10.dat*" -mtime 0 -print0 | xargs -i -0 cp "{}" /cerner/d_p19/ccluserdir [/code]

Member Avatar for ghostdog74
0
98

The End.