Programming :: Perl Script Output Can't Be Redirected To A File / Sort It?

Feb 18, 2010

The perl script I wrote works fine if I print the result to screen
x0_amber.pl 1 1000 0 5

But whenever I want to output to a file with
x0_amber.pl 1 1000 0 5 > x0_out

it never really prints out to the file.

It worked earlier, but I was playing with my PATH lately, I don't know if it's related to that

View 7 Replies


ADVERTISEMENT

Programming :: [Perl] Fail To Sort A File With 300,000 Lines By Multiple Columns?

Nov 10, 2009

Each line of the file I am sorting is in the following format:

<url> <month> <day>

For example:

[URL]

I wrote the following to sort:

Code:

#!/usr/bin/perl
$in = shift;
chomp($in);

[code]....

The script worked fine for my small testing files, but failed in my input file. The input file is 18MB and containing more than 300,000 lines. The output will contains some lines like that:

url_one 10 1
url_two 10 1
url_three 10 3
url_four 10 1

Is that because my file is too big for perl to handle ?

View 10 Replies View Related

Programming :: Use Regex In Perl Script To Detect Allowed Words From The File And Then Print Output To The Screen?

Oct 4, 2010

Its my first post in here so please be patient I am trying to use regex in perl script to detect allowed words from the file and then print output to the screen.

As an example : I have text file with orders and returns :

Item2-SKU-2-11.08.2010-online
Item3-SKU-3-11.09.2010-return
Item4-SKU-4-11.09.2010-store

My question: is it possible to make sure that i am ony outputing to the screen orders based on few conditions like Item,order form e.g. online.And is it possible to have multiple matches (Item2 only diplay if ordered online etc)

View 1 Replies View Related

Programming :: Sort Hash Of Hashes By Value In Perl?

Dec 1, 2010

I have a hash of hashes and I need to sort this by value and write to a javascript array file..Currently I am using the following

foreach my $key(sort { keys %{$trans{$a}} <=> keys %{$trans{$b}}} keys %transmission)
{
foreach my $role(sort {$trans{$key}{$a} cmp $trans{$key}{$b}} keys %{$trans{$key}})

[code]...

View 2 Replies View Related

Programming :: Output Coming In New Line In Perl?

Feb 22, 2010

Here is some line I have written in perl to show my name :

[code]...

And after stdin kumar, its giving the output as

[code]...

output should be [code]... but why its coming in two lines?

View 2 Replies View Related

Programming :: Assigning Output Of A Command To An Array In Perl?

Nov 25, 2010

I am trying to execute a Unix Command in perl and assigning its output to an array:

Code:
@File_List=exec("ls -1 /tmp");
but it is not working. I have tried the perl function system() also but its return code is

[code]...

View 10 Replies View Related

Programming :: Sort Command Output Differs When Encounters?

Mar 18, 2010

Here is what I am doing I have a file, a.txt for example, with following contents:

Code:
coreutils install
cpio install
cpp install
cpp-4.3 install
dbus install

[Code]...

So it seems like the sorting algo. for dpkg --get-selections is different than sorting algo. of 'sort' command when it encounters "-" (hyphen). How can I sort the original file (a.txt) in such a way that it produces the output file ,b.txt, exactly the same.

View 6 Replies View Related

Ubuntu :: Sort The Output To A Text File So That It Prints To The Text File At 1 Process Per Line?

Feb 6, 2011

im trying to output a list of running processes via a shell script. At the moment i got this which outputs the processes to a text file called out.

echo $(ps aux) >>out

The problem is though, the processes are all just one big block of text which makes it hard to read. Does anyone know how to sort the output to a text file so that it prints to the text file at 1 process per line? I know its probably simple but im very new to linux.

View 5 Replies View Related

Programming :: Perl Find File And Then Replace String In File

Jul 28, 2009

I have script that I'm working on that updates a username in all the files that are called blah.inc for my framework. since i host a bunch of these web apps i need to do it to all of them. so I need to figure out how to update these files automagically with out me watching it to call vim every time. heres what I have so far

Code:

This finds the files but now i need to figure out how to do s/bob/fred/g on those files.

View 5 Replies View Related

Programming :: Split A File To Multiple File Using Awk Or Perl?

Feb 27, 2011

I have a single file that contain multi-text something likes this:

Quote:

No. Time Source Destination Protocol Info
185 27712.068199 192.168.18.23 192.168.18.191 SMTP S: 250 2.1.5 Ok
No. Time Source Destination Protocol Info
186 27715.068293 192.168.0.50 192.168.5.2 TCP suncacao-jmxmp > 44693 [ACK] Seq=1 Ack=1 Win=64807 Len=1380

[Code].....

View 14 Replies View Related

General :: Wget A File With Correct Name When Redirected?

Jun 23, 2011

I was unable to find an answer to something that (I think) should be simple:

If you go here: [URL]

like so:

wget [URL]

you'll probably end up with a file called "download_script.php?src_id=9750"

But I want it to be called "molokai.vim", which is what would happen if I used a browser to download this file.

Question: what options do I need to specify for wget for the desired effect?

I'd also be ok with a curl command.

View 2 Replies View Related

Programming :: Perl : Get Maxdate From The File?

Apr 7, 2010

I have a input file like below :

949890;01-4477138;20101208;7003907933;0
1352305;01-32175;20101225;7005373440;0
0771586;03-975357;20091206;7004353176;0

[code]....

View 1 Replies View Related

Programming :: Perl: Parsing A Log File?

Nov 9, 2010

I have a log file (test.log) starting & ending within dash (--) as below. I am looking to write a parser for test.log. This test.log file currently has single value for one Job ID but I wish to parse for repeated N values of different Job ID - Job, User, Queue, Dispatched Date, Dispatched Time, Completed Date, Completed Time, Hosts/Processor, CPU_T and TURNAROUND. I can either output this 10 values in another .log file or dump into cgi.

The selected parameters from test.log for parsing with above 10 attributes are -

--
Job <345010>
User <xyz>
Queue <gaussian>

[code]....

View 3 Replies View Related

Programming :: Writing File In Perl/cgi?

Apr 10, 2010

I'm not able to write to a file using my perl cgi script which is as fallows:

Code:
#!/usr/bin/perl -w
use strict;
print "Content-type: text/html

[Code]....

View 4 Replies View Related

Programming :: Cutting An Html File Apart - Perl - Sed - Awk?

Apr 13, 2010

I have an html file like this

HTML Code:

Some more HTML code... I would like to cut the above text so i get this: Sometext on multiple lines like this.Sometext on multiple lines like this.Sometext on multiple lines like this. Sometext on multiple lines like this.Sometext on multiple lines like this.

There are other HTML files with similar cuts I need to do, but once I have the method for doing one, I am sure I can do the others.

I think the two logical strings to cut between would be:

I am not sure if these strings are always the start and end of the line respectively, is this makes a lot of difference! Then the HTML tags would need to be stripped to get the text on its own.

I know the commands for removing tags, but searching for a string like class="IOSSectionTitle", and cutting everything before it etc is something I am finding challenging.

Just thought I would add that the HTML does not nec. appear on logical new lines throughout the file and there may be unexpected new lines, but as far as i know the class="IOSSectionTitle" and <img always appears as a string without any new lines between those characters.

View 4 Replies View Related

Programming :: Ngram Text File Using Perl?

Mar 6, 2011

I have a few problem. I have txt file like this:Quote:00 21 55 84 9a ff 00 1f 9e 1a 5b 00 08 00 45 00 00 4b 00 00 40 00 3f 11 9a 0e a1 8b fa 02 04 02Then, based on my txt file, I would like to generate text like this:Quote:00215584 2155849a 55849aff 849aff00 9aff001f ff001f9e 001f9e1a 1f9e1a5b 9e1a5b00 1a5b0008 5b000800 00080045 08004500 00450000 00004b00 004b0000 4b000040 00004000 0040003f 40003f11 003f119a 3f119a0e 119a0ea1 9a0ea18b 0ea18bfa a18bfa02ased in my reading, I found about ngram solution in perlbut I not really understand to edit from source code given. I m begineer user in programming language. I hope to get the solution. [URL]

View 1 Replies View Related

Programming :: Perl - Grep Open File More Then Once?

Jul 16, 2011

I am using File::Find to go through a very large tree. I am looking for all xml files and open only those that contain a tag <Updated>. I then want to capture the contents of two tags <Old> and <New>.

My problem is, after I open the file and do the first grep for <Updated> (which does work), I am unable to grep again unless I close the file and open it.

I did something like this:

Quote:

find(&check, $dir);
sub check {
if ($_ =~ /.xml/){
open(FILE,"$_");
if (grep{/Updated/} <FILE>){ # <-- works

[Code]....

View 6 Replies View Related

Programming :: Perl Script To Look At A Directory For A New File?

Oct 23, 2009

I am new to programming but I am a quick study. I have this script working.

#!/usr/bin/perl
@info=stat("/share/") or die "Can't stat share $!";
while (1) {

[code]...

View 2 Replies View Related

Programming :: Read File Names In A Dir And Its Sub Dir In Perl?

Apr 22, 2010

I am writing a script that involves reading the content of a file present in a directory and/or its sub directory. I know readdir returns all the files & DIR names in a directory but how to check weather readdir is returning a file or a directory

View 2 Replies View Related

Programming :: Reading Lines Within A File (Perl)?

Mar 16, 2011

I am trying to read certain lines within a file and give the output of the certain lines that dont equal my value, I think showing you would be easier. There is multiples of these inside one file...

Code:

LV Name /dev/vg00/lvol1
LV Status available/syncd
LV Size (Mbytes) 300lable/syncd

[code]....

I want to read everything in the file, if the status is not available then it should display the name (directly above status). If they are all availbale then do nothing. I think I know how to do it which includes putting the info in string form and placing in hash but it is proving to be out of my skill range.

View 12 Replies View Related

Programming :: Replace String In File Using Perl Or Sed

Jun 30, 2011

I have question about replacing a string in a file.

How can I replace the printerb's 10.1.1.1 to something else(10.1.1.2, for example) without replace printera's 10.1.1.1 accidentally?

I have tried perl -e -pi "s/10.1.1.1/10.1.1.2/g" /etc/hosts. but, perl replace both 10.1.1.1 to 10.1.1.2.

View 13 Replies View Related

Programming :: Unable To Append To A File Through Perl/CGI

Apr 6, 2010

where I'm trying to demonstrate the file locking concept through Perl/CGI.Here is the script which I tried.

Code:
#!/usr/bin/perl -w
use strict;
use warnings;
print "Content-type: text/html

[Code].....

View 2 Replies View Related

Programming :: Deleting Rows From Text File In Perl?

Jun 21, 2010

How can I delete rows into text file in perl?

View 4 Replies View Related

Programming :: Delete Multiple Lines In A File Using Perl?

Apr 15, 2011

I have a file looks like the following:

digraph topology
{
"192.168.3.254" -> "10.1.1.11"[label="1.000", style=solid];
"192.168.3.254" -> "10.1.1.12"[label="1.000", style=solid];

[code]...

Order of these lines are random... So I cannot delete line #19, for example... And you can see that top four lines I want to delete are pairs. So there might be some clever way to detect the lines, if a line has both "1.9" and "1.11", then delete the line... I am new to perl language. The following is the code I have now... I think I just need to write some code inside the while loop checking if I want to delete the line $dotline before I write to a NEW file.

Code:

#!/usr/bin/perl -w
$TOPPATH = "/tmp";
$NAME = "topology";
$FILENAME = "$TOPPATH/$NAME.dot";

[code]....

View 16 Replies View Related

Programming :: Zip A Variable With PERL Without Reading Or Writing A File?

Jun 20, 2010

There is the Archive::Zip I think I can use with Perl 5.10 but I don't know how. I don't want to read or write any files, just zip something in memory, with best compression, like

$text = "this is a test";
$zippedtext = &Zip($text);
sub Zip {

[code]...

I guess it's only a few lines.

View 3 Replies View Related

Programming :: Perl - Counting Files With File - Find

Dec 20, 2010

So this is my code:

Code:

Modification of code I found here. It works, but I don't really know why.

Q1: Why is each filter hit counted only when the conditional is not true?

Q2: I've tried taking the file type, (.old), and put it into a variable for better usability, but then the script fails.

View 14 Replies View Related

Programming :: Perl Read File And Parse Blocks?

Aug 21, 2010

I am trying to make a perl script which reads data from a file and parse it. The data in the file has the following syntax

Code:
Device Physical Name : Not Visible
Device Symmetrix Name : 1234
Device Serial ID : N/A
Attached BCV Device : N/A
Device Capacity

[Code]...

Each unique record starts with "Device Physical Name". So, I have a set of records within "Device Physical Name". I want to read this set of records starting from "Device Physical Name" and ends up till next "Device Physical Name". Offcourse FS is ":", and I just want to print/or later put info in a csv file.

View 14 Replies View Related

Programming :: Perl - Writing To File - Keep Open Or Only During Write?

May 24, 2011

i am working on this thread: [URL] if it is better to open a file every time i need to write to it or should i keep a file open the whole time and when i am done with the script, close it and sendmail it out?

Or i just thought of this: i could keep concatenating to a string and just sendmail when done.

View 2 Replies View Related

Programming :: Concatenate File Sort By Date?

May 5, 2010

i have text file that filename contain the date of creation (i.e 2010.05.02.log).I would like to create a script that:-Ask for start date -Ask for end date- Concatenate all file on the requested period by date order.

View 1 Replies View Related

Programming :: Convert Multiple File In Directory - Ascii To Hex In Perl ?

Apr 9, 2011

I have found a perl script that can convert single file: ascii to hex.

However I have thousand of file that I want to convert from ascii to hex.

Here is the perl script that convert single ascii file to hex in single line:

Quote:

So I would like to read multiple file from a directory.

Then the file will be have same name file with hex data.

Here is sample of the read and write directory file.

Quote:

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved