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


ADVERTISEMENT

Red Hat :: Convert A Unicode File To Ascii?

Jul 1, 2010

I need to be able to convert a unicode file to ascii using red hat.

View 1 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 :: 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 :: Convert Binary File In To Ascii File Using Shell Script?

May 23, 2011

i am trying to convert a binary file in to ASCII using shell script. this file contains multiple types of data like string, number, bcd, etc.

View 5 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

General :: Tool To Convert A File Of HEX To ASCII Character Set?

Feb 10, 2011

Is there a known tool to convert a file consisting of 2 byte Hex into ascii?

Note: - Maintain file offset listing in bytes code...

View 3 Replies View Related

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

Server :: Convert A Hex File To An ASCII File?

Sep 8, 2010

I have a file of 2GB size in hex form. This is a log file from the server which I converted to hex as the file got corrupted.Can anyone tell how to convert this hex file to ASCII?

View 1 Replies View Related

Red Hat / Fedora :: Convert Plain Text File To Html File Without Using Perl?

Jun 9, 2010

I am looking for some source package which will convert plain text file to html file without using perl.

I mainly need to do this on an ARM platform, so if I get sources I can cross compile it.

View 5 Replies View Related

Programming :: Perl - Directories Given To Opendir Via Foreach Give "No Such File Or Directory" Error

Feb 19, 2009

I'm writing a perl script to remove a test database and part of that is of course getting rid of all files. So I wrote this to do the job:

Code:

This always results in an "Could not open /u00/app/oracle/product/10.2.0/rdbms/dbs for reading: No such file or directory" (that directory is the one ending with the $spfile_dir variable) message, although that directory exists and the executing user has writing rights on it.

The same behaviour if I create the directory array like this:

Code:

The problem does not occur when one of the directories is the only element in the array though. Of course I could copy and paste that part of the script for the second directory, but I don't like that workaround.

View 1 Replies View Related

Programming :: Prepend To ASCII Text File In C?

Jun 15, 2010

To start off I would like to acknowledge that I am not a very good C programmer and pretty much everything I know has been self taught through mostly trial and error. So forgive me if there is an obvious answer to my question, or if I don't immediately grasp the concepts involved in the possible solution.

Basically, I'm writing an application which will be creating log file entries rather rapidly (potentially hundreds per minute), and I would like each new line to appear at the top of the log file, rather than the end. Opening a text file in append mode is easy enough, but I can't seem to find any obvious way to do the opposite.

I have been looking online and it seems that there exists no standard way to do this, and I have only been able to find a few mentions of how somebody might achieve it. The most common method seems to be using two files and copying the data back and forth between them. This seems like it would be insanely I/O intensive with the number of lines I'm likely to be generating. If this is the best method to use, I will give it a shot; though I am not 100% clear on how to implement it, I am also open to any other ideas as to how to accomplish this, and I don't have to worry about portability since the program already uses Linux-only libraries. So calling out to sed or something is not necessarily out of the question (though I imagine performance would also be an issue there).

View 4 Replies View Related

Software :: Perl Program Can't Convert A Csv File (with Japanese Characters) / What To Do?

Jan 20, 2011

I use the below perl program csv2xls.pl can convert a csv to xls file , it works fine , but I found that it only work for all English characters , I tried to use it to convert a csv file ( with Japanese characters ) , it does work , I also tried the perl "unicode_utf16_japan.pl" , it also did not work , can advise what can i do ?

View 13 Replies View Related

Debian :: Perl Script - Converting Unicode To ASCII?

May 7, 2010

I'm trying to write a Perl script that will convert text to ASCII. I'm particularly interested in converting files created with MS Windows, so I used Notepad to create a few test files.

I have had some success with the following script:
[[ Script Deleted -- see subsequent posts ]]

After coming back /home/ to Debian, I used file to examine the file types:
$ file ansi.txt unicode_big-endian.txt unicode.txt utf8.txt
ansi.txt: ASCII text, with CRLF line terminators
unicode_big-endian.txt: Big-endian UTF-16 Unicode character data, with CRLF line terminators
unicode.txt: Little-endian UTF-16 Unicode character data, with CRLF, CR line terminators
utf8.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators

After running:
$ uni2ascii.pl -i ansi.txt -c ASCII -o new_ansi.txt
$ uni2ascii.pl -i unicode_big-endian.txt -c utf16 -o new_unicode_big-endian.txt
$ uni2ascii.pl -i unicode.txt -c utf16 -o new_unicode.txt
$ uni2ascii.pl -i utf8.txt -c utf8 -o new_utf8.txt

Everything appears good:
$ file new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
new_ansi.txt: ASCII text
new_unicode_big-endian.txt: ASCII text
new_unicode.txt: ASCII text
new_utf8.txt: ASCII text

But the "little-endian file" does not convert properly:
$ md5sum new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt
c4def7932bc151b9e786b6ca1299162c new_ansi.txt
c4def7932bc151b9e786b6ca1299162c new_unicode_big-endian.txt
5b62a013dced4f2c2c0af45ea6388c1e new_unicode.txt
c4def7932bc151b9e786b6ca1299162c new_utf8.txt

When I use cat to print the new_unicode.txt file in an Emacs terminal, a ^@ appears on the last (empty) line. When I open the new_unicode.txt with KWrite, a warning message tells me that the file is a "binary" and "saving it will result in a corrupt file."

View 14 Replies View Related

Programming :: Indexing Multiple Drives With Perl?

May 7, 2010

I have 4 separate drives, all un-RAIDed.Each drive has almost the same root directories, but different contents in each folder.

For example:

/mnt/sda/TV Shows/Lost/
/mnt/sdb/TV Shows/Your_Favorite_Show/

The goal is to have a single folder that has symlinks to all the files in each of the drives. Pretty much a poor man's JBOD. Previously, I had problems with conditions like 2 drives having the same sub folder contents, but I ended up solving that with the current script I'm using now.What I'm looking for now is speed. I'm very new to Perl and the script takes about 12 minutes to complete with the current drives.

Basically, the script makes a list of all directories and files in each drive. First, it makes the directories. I didn't use any validation because if a directory already exists, it simply won't make one. However, with the files, I used a hash to only keep the unique files. Then I use the key/value pairs with ln to create every link to the files only, not directories.

Code:

#!/usr/bin/perl
use warnings;
my @drives_to_sync = qw ( /mnt/sda/ /mnt/sdb/ /mnt/sdc/ /mnt/sdd/);

[code].....

View 2 Replies View Related

Programming :: Perl - Multiple Child Processes In Parallel?

Sep 3, 2010

I'm looking for a way in Perl to be able to take a list of servers, ssh multiple commands to it and store the results. If I do this process serially, sometimes one server will hang the whole script and if it doesn't, it still takes hours to complete.

I'm thinking what I need to do is make a parent loop that calls out a separate process that passes the server name to the child sub process and then executes all the commands I have defined in its own process. If one server 'hangs', at least that won't stop the script from doing all the other servers in the list.

I'm guessing using the fork() command would serve me best, however, all the online descriptions I have found have been vague at best.

View 4 Replies View Related

Programming :: Unable To Match Across Multiple Lines In Perl

May 11, 2011

I'm trying to split a text file into various parts. Everything in between "123" and "break" (including linebreaks) goes into the splitted file.

e.g. using this text file:

This should split into 4 files. However I'm only getting 2 files: one for the line "123break" and one for "123 blah break". The two occurrences that contain linebreaks are being ignored. The .* part of my match should capture linebreaks seeing that I'm using the /s modifier shouldn't it? Even when I use the match /(123 break)/gs it still doesn't capture the first occurrence. I'm using Perl v5.12.3 (from ActiveState) on Windows XP. The text file is also in Windows format.

Code listed below.

The above code generates two files Output_1.txt and Output_2.txt which contain "123break" and "123 blah break" respectively. I want it to generate four files.

View 4 Replies View Related

General :: Convert Text To ASCII?

May 20, 2010

how i can convert a text to ASCII? >>> ( to encrypt the text ) and how can we use the "hexdump"

View 5 Replies View Related

Programming :: Perl Regex Not Matching Across Multiple Lines Despite Ms Flags / Fix It?

Aug 16, 2010

I have written a regular expression (tested in regexpal and regextester alpha something) with which I want to replace something like code...

but it only matches functions which occupy one line only, despite my tests showing multiple line matching in javascript testers online and using the m and s flags (which should make it multi line no?)

View 14 Replies View Related

Programming :: Perl's Length() Counts Umlauts Multiple Times

Dec 14, 2010

I'm programming some skript to get statistical information about some texts. This includes calculating the mean of word lengths.Unfortunately, Umlauts count as two characters. In the example below the output is 9, it should be 6.

sincercly, Max

Code:
#!/usr/bin/perl
use POSIX;
use locale;
my $test = length("ABC���");
print $test;

View 4 Replies View Related

General :: Convert To ASCII Format Under OpenWrt?

Feb 16, 2011

[URL] under Fedora 14 - Bash:
$ cat asdf | iconv -c -t ASCII
<a href="http://www.net-security.org/secworld.php?id=10607">biometric cabinet lock detects life in the finger</a>
ASDF
$
[Code]...

But theres no iconv under OpenWrt. Are there other working methods to convert a piped ( "|" ) text to only ascii format (under OpenWrt 10.03)?

View 1 Replies View Related

General :: Convert The Numbers Back Into Their Corresponding ASCII Character

May 19, 2010

To encrypt the text, we take the word "python" and make it at least the same size as "welcome home" by repeating it as follows:

w e l c o m e h o m e
p y t h o n p y t h o n
Then, we convert each letter into its numerical ASCII value as follows:
w e l c o m e h o m e = 119 101 108 099 111 109 101 032 104 111 109 101

[Code].....

And, finally, we convert the numbers back into their corresponding ASCII character:

View 11 Replies View Related

General :: Convert Binary Number To Text/ascii?

Mar 16, 2011

is there command in linux which is able to convert binary (0101001010000100) to text like it means something

View 4 Replies View Related

Debian Programming :: Using Perl To Replace Filename Strings In A Directory

Jun 12, 2013

I have a directory of orchestral music .ogg files from a family member. Each track is from a different artist and the CDDB entry adds a ":" character after the artist name in the track title.

Here is an example of what I am referring to:

Code: Select all13_-_Mozart:_Sonata_in_A_major_KV_331.ogg

I would like to parse file names in any given directory and search for the string Code: Select all: and replace it with Code: Select all_ According to this post on stackoverflow, I can use Perl to accomplish this task. I've tried Code: Select allperl -i.bak -pe 's/:/_/' but since I am still learning Perl I'm probably commiting a PEBKAC error.

How would I go about solving this issue with regular expressions using Perl?

View 3 Replies View Related

Programming :: Change Current Working Directory Through A Perl Script?

May 2, 2010

how can i actually switch to another directory with "chdir" in perl.like the we used to do is bash as:

Code:
$cat abc
cd Desktop/

[code]...

View 1 Replies View Related

CentOS 5 :: Convert Between "ASCII English Text" And "ASCII Text"?

Aug 3, 2011

This is weird, and I never noticed before, but now I have an application that is borking on weird things like when /etc/hosts is of one file format or another, and I don't even know the difference between the two (google doesn't tell much either). on CentOS 5.5/5.6 x86_64: a which on the following is an interesting tell:

vi = /bin/vi
vim = /usr/bin/vim

both are actually vim version 7.0.237 but sum differently, and although they are both actually separate executables in the stock installs of CentOS I've been building, on most distros, and older versions of CentOS it seems, vi is usually just a symlink to vim - but again, not in these fresh installs it seems. When I create a file with the 'vi' above, it defaults (usually) to "ASCII text" (but not always) When I create a file with the 'vim' above, it defaults to "ASCII English text" (and causes a particular application I'm working with to bork and barf). It seems the OS is installed by default yielding both file types too, as evidenced by the following:

[Code]...

View 4 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 :: 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







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