Sponsored Content
Top Forums Shell Programming and Scripting conversion of code in perl and python Post 302690933 by learnbash on Thursday 23rd of August 2012 03:07:09 PM
Old 08-23-2012
conversion of code in perl and python

How to convert below bash code in perl and python.

Code:
for BLOCK in /sys/block/emcpow*
do
        echo "100000" > "$BLOCK"/queue/nr_requests
        echo "noop" > "$BLOCK"/queue/scheduler
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Code conversion from JSP to PYTHON

Guys I need to convert a code from JSP (Java Tags are also there inside JSP) to PYTHON. I have OK kind of knowledge in PYTHON, but dont have a muck knowledge in JAVA/JSP. Any idea how to approach? Thanks in advance to all C Saha (1 Reply)
Discussion started by: csaha
1 Replies

2. UNIX for Dummies Questions & Answers

Another bash shell to perl conversion

Hello everyone. I am new to linux and need help again. I need help converting this bash shell to linux: for i in `ls -l *.txt` do `./cnvidtf.pl $i` `curl -u login:pswd --disable-espv -T loadfile.seq ftp://11.1.11.1` `mysql -u login -h 11.1.11.1 -ppswd < lddocs.sql` done Thanks! Any help... (6 Replies)
Discussion started by: freak
6 Replies

3. Shell Programming and Scripting

[Perl] Timestamp conversion

Hi, I have searched, read and tried, but no luck. I have this code: #!/bin/perl -w #-d use strict; use POSIX qw(strftime); my $getprpw_list="/usr/lbin/getprpw -l"; my $host = "nbsol151"; my $user = "genadmin"; my %uid; my %spwchg; my %upwchg; my %slogint; (2 Replies)
Discussion started by: ejdv
2 Replies

4. Shell Programming and Scripting

Perl Conversion Tool

I want a perl script that converts special characters (French, German, Italy, Denmark character set) into database compatible format and retrieves the back in the original format. A generic functionality will be developed which converts any special characters (having > 8 bit format). I tried... (3 Replies)
Discussion started by: perl2ask
3 Replies

5. Shell Programming and Scripting

perl instead of grep 'conversion' help?

Hello: I butchered a shell script together, but my script kung-fu is 5 years old and all I've used for 5 years are for i loops. I hope that some perl guru can do in 5 minutes what takes me 5 weeks, so I am asking for help. I have a simple script using "grep -A 2 'string' /path/to/file" but... (4 Replies)
Discussion started by: Habitual
4 Replies

6. Shell Programming and Scripting

[python]string to list conversion

I have a file command.txt. It's content are as follows:- The content of file is actually a command with script name and respective arguments. arg1 and arg2 are dummy arguments , format : -arg arg_value test is a argument specifying run mode , format : -arg In my python code, i read it and... (1 Reply)
Discussion started by: animesharma
1 Replies

7. Shell Programming and Scripting

Timestamp conversion in PERL

Hi, I have a file as below I need to overwrite the 2 nd column alone to numeric format like "06122011030414012345" as per the timestamp value output file should be the microseconds can be neglected if required. Any help will be appreciated. Thanks in advance (1 Reply)
Discussion started by: irudayaraj
1 Replies

8. Shell Programming and Scripting

conversion of loop in perl

Hello Sir, How can i convert below two loop lines in perl for BLOCK in /sys/block/myblock* for BLOCK in /dev/myblock* How i can write them in perl like foreach( </sys/block/myblock*/queue/nr_requests> ) (5 Replies)
Discussion started by: learnbash
5 Replies

9. Programming

Python conversion to epoch time

Hi. I have timestamps that I am trying to convert to epoch time. An example: I am trying to convert this to an epoch timestamp but have one little glitch. I have this: import time date_time = '' pattern = '' epoch = int(time.mktime(time.strptime(date_time, pattern))) print epoch... (1 Reply)
Discussion started by: treesloth
1 Replies

10. Shell Programming and Scripting

Python soap and string to .xlsx conversion

Hi experts - I'm relatively new to python, but I have an requirement to automate getting a file from a WebLib server using an API. The file I'm requesting from this sever is an excel spreadsheet (.xlsx). I get a valid response back via an xml doc from the server. In this xml file I get... (8 Replies)
Discussion started by: timj123
8 Replies
Test::LeakTrace(3pm)					User Contributed Perl Documentation				      Test::LeakTrace(3pm)

NAME
Test::LeakTrace - Traces memory leaks VERSION
This document describes Test::LeakTrace version 0.14. SYNOPSIS
use Test::LeakTrace; # simple report leaktrace{ # ... }; # verbose output leaktrace{ # ... } -verbose; # with callback leaktrace{ # ... } sub { my($ref, $file, $line) = @_; warn "leaked $ref from $file line "; }; my @refs = leaked_refs{ # ... }; my @info = leaked_info{ # ... }; my $count = leaked_count{ # ... }; # standard test interface use Test::LeakTrace; no_leaks_ok{ # ... } 'no memory leaks'; leaks_cmp_ok{ # ... } '<', 10; DESCRIPTION
"Test::LeakTrace" provides several functions that trace memory leaks. This module scans arenas, the memory allocation system, so it can detect any leaked SVs in given blocks. Leaked SVs are SVs which are not released after the end of the scope they have been created. These SVs include global variables and internal caches. For example, if you call a method in a tracing block, perl might prepare a cache for the method. Thus, to trace true leaks, "no_leaks_ok()" and "leaks_cmp_ok()" executes a block more than once. INTERFACE
Exported functions "leaked_info { BLOCK }" Executes BLOCK and returns a list of leaked SVs and places where the SVs come from, i.e. "[$ref, $file, $line]". "leaked_refs { BLOCK }" Executes BLOCK and returns a list of leaked SVs. "leaked_count { BLOCK }" Executes BLOCK and returns the number of leaked SVs. "leaktrace { BLOCK } ?($mode | &callback)" Executes BLOCK and reports leaked SVs to *STDERR. Defined $modes are: -simple Default. Reports the leaked SV identity (type and address), file name and line number. -sv_dump In addition to -simple, dumps the sv content using "sv_dump()", which also implements "Devel::Peek::Dump()". -lines In addition to -simple, prints suspicious source lines. -verbose Both -sv_dump and -lines. "no_leaks_ok { BLOCK } ?$description" Tests that BLOCK does not leaks SVs. This is a test function using "Test::Builder". Note that BLOCK is called more than once. This is because BLOCK might prepare caches which are not memory leaks. "leaks_cmp_ok { BLOCK } $cmp_op, $number, ?$description" Tests that BLOCK leaks a specific number of SVs. This is a test function using "Test::Builder". Note that BLOCK is called more than once. This is because BLOCK might prepare caches which are not memory leaks. "count_sv()" Counts all the SVs in the arena. Script interface Like "Devel::LeakTrace" "Test::LeakTrace::Script" is provided for whole scripts. The arguments of "use Test::LeakTrace::Script" directive is the same as "leaktrace()". $ TEST_LEAKTRACE=-sv_dump perl -MTest::LeakTrace::Script script.pl $ perl -MTest::LeakTrace::Script=-verbose script.pl #!perl # ... use Test::LeakTrace::Script sub{ my($ref, $file, $line) = @_; # ... }; # ... EXAMPLES
Testing modules Here is a test script template that checks memory leaks. #!perl -w use strict; use constant HAS_LEAKTRACE => eval{ require Test::LeakTrace }; use Test::More HAS_LEAKTRACE ? (tests => 1) : (skip_all => 'require Test::LeakTrace'); use Test::LeakTrace; use Some::Module; leaks_cmp_ok{ my $o = Some::Module->new(); $o->something(); $o->something_else(); } '<', 1; DEPENDENCIES
Perl 5.8.1 or later, and a C compiler. CAVEATS
"Test::LeakTrace" does not work with "Devel::Cover" and modules which install their own "runops" routines, or the perl executor. So if the test functions of this module detect strange "runops" routines, they do nothing and report okay. BUGS
No bugs have been reported. Please report any bugs or feature requests to the author. SEE ALSO
Devel::LeakTrace. Devel::LeakTrace::Fast. Test::TraceObject. Test::Weak. For guts: perlguts. perlhack. sv.c. AUTHOR
Goro Fuji(gfx) <gfuji(at)cpan.org>. LICENSE AND COPYRIGHT
Copyright (c) 2009-2010, Goro Fuji(gfx). All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-10-07 Test::LeakTrace(3pm)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy