Sponsored Content
Top Forums Shell Programming and Scripting Converting a binary file to ascii and vice versa? Post 302859405 by baranisachin on Thursday 3rd of October 2013 04:35:38 AM
Old 10-03-2013
Hi Scoot,
THanks for the reply, As i told its a file extracted from a database table with '~' as a delimitter; The file might contain arbitrary No. of columns each time. Strings is not converting the entire file properly as expected. Is there any other command/script that will help me?
 

10 More Discussions You Might Find Interesting

1. Programming

binary to string conversion and vice versa

please let me know that in unix using c programming language we can do binary to string conversion and vice versa using ltoa and atol but how can we do it in c++ programming language. thank you in advance. (3 Replies)
Discussion started by: kinnaree
3 Replies

2. UNIX for Advanced & Expert Users

Converting ASCII to Binary mode

Dear All, Business Users are transfering ( FTP ) a CSV file into the IBM AIX box with transfer mode as ASCII. But I want to convert the CSV file from ASCII mode into binary mode, as my script expects file in binary mode. Is it possible to do through Unix commands? Thanks in Advance, RK (1 Reply)
Discussion started by: srajeshmca
1 Replies

3. Shell Programming and Scripting

Pdf to text conversion and vice versa

Hi, I have a pdf file. i want to convert it to text file and do some work on it and later want to convert it back to pdf. Can this be done via unix? or Is there a way unix can directly work on PDF file? (2 Replies)
Discussion started by: saltysumi
2 Replies

4. UNIX for Dummies Questions & Answers

Appending from a file to a script and vice versa

Hi, I am new to Unix and discovered this example problem online that I believe will help my learning: Run the command's below env >> xx env >> xx env >> xx env >> xx env >> xx You will now have a file called XX with the env redirected into it 5 times Create a script named... (2 Replies)
Discussion started by: Jimmy_c
2 Replies

5. Shell Programming and Scripting

Uppercase to lowercase and vice versa

shell script to convert file names from UPPERCASE to lowercase file names or vice versa in linux anybody please help me out!!!! (5 Replies)
Discussion started by: jacky29
5 Replies

6. Ubuntu

What is the advantage of ubuntu over vista and vice versa?

i am thinking of replacing my vista with ubuntu. Questions: 1) what will be the advantages and disadvantages of using ubuntu instead of vista? 2) what will be the setbacks of replacing my vista? 3) how hard is it to cope up with the new OS? what must i learn to utilize ubuntu? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

7. Shell Programming and Scripting

Converting from Centigrade to Fahrenheit and vice versa.

I need to write a script that will take the input from a file and convert the number from centigrade to fahrenheit and vice versa. This is what I have but it doesn't seem to be correct. Also the data file has 11 numbers inside of it and the output needs to be listed as so: Fahrenheit Temperature... (18 Replies)
Discussion started by: N1ckNak
18 Replies

8. UNIX for Dummies Questions & Answers

How to ping from Windows to Solaris 10 and vice versa?

Hi all, I installed Oracle virtual box 4.1.8 on my desktop. I installed Windows 2008 server R2 as one instance and Solaris 10 as another instance. When am trying to ping from Windows to solaris and vice-versa, ping not working. windows IP : 10.1.47.24 Solaris IP : 10.1.47.25 netstat... (2 Replies)
Discussion started by: kjks
2 Replies

9. Shell Programming and Scripting

Converting odd values to even values(or vice-versa) located in a column

Hello All, I have a below data in a .csv file where all rows where col1 is A, col2 is odd numbers, similarly even numbers for all rows where col1 is B. Note that my data has some other columns(not shown here) too (around 100) after col2. Tool,Data A,1 A,3 A,5 .... so on B,2 B,4 .... ... (4 Replies)
Discussion started by: ks_reddy
4 Replies

10. UNIX for Dummies Questions & Answers

Command for Host Name to IP Address or Vice Versa

Hi, In unix or linux is there any command exist to identify Host Name to IP Address or Vice Versa? Thanks in advance (6 Replies)
Discussion started by: nag_sathi
6 Replies
Log::Handler::Output::DBI(3pm)				User Contributed Perl Documentation			    Log::Handler::Output::DBI(3pm)

NAME
Log::Handler::Output::DBI - Log messages to a database. SYNOPSIS
use Log::Handler::Output::DBI; my $db = Log::Handler::Output::DBI->new( # database source database => "database", driver => "mysql", host => "127.0.0.1", port => 3306, # or with "dbname" instead of "database" dbname => "database", driver => "Pg", host => "127.0.0.1", port => 5432, # or with data_source data_source => "dbi:mysql:database=database;host=127.0.0.1;port=3306", # Username and password user => "user", password => "password", # debugging debug => 1, # table, columns and values (as string) table => "messages", columns => "level ctime cdate pid hostname progname message", values => "%level %time %date %pid %hostname %progname %message", # table, columns and values (as array reference) table => "messages", columns => [ qw/level ctime cdate pid hostname progname message/ ], values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # table, columns and values (your own statement) statement => "insert into messages (level,ctime,cdate,pid,hostname,progname,message) values (?,?,?,?,?,?,?)", values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # if you like persistent connections and want to re-connect persistent => 1, ); my %message = ( level => "ERROR", time => "10:12:13", date => "1999-12-12", pid => $$, hostname => "localhost", progname => $0, message => "an error here" ); $db->log(\%message); DESCRIPTION
With this output you can insert messages into a database table. METHODS
new() Call "new()" to create a new Log::Handler::Output::DBI object. The following options are possible: data_source Set the dsn (data source name). You can use this parameter instead of "database", "driver", "host" and "port". database or dbname Pass the database name. driver Pass the database driver. host Pass the hostname where the database is running. port Pass the port where the database is listened. user Pass the database user for the connect. password Pass the users password. table and columns With this options you can pass the table name for the insert and the columns. You can pass the columns as string or as array. Example: # the table name table => "messages", # columns as string columns => "level, ctime, cdate, pid, hostname, progname, message", # columns as array columns => [ qw/level ctime cdate pid hostname progname message/ ], The statement would created as follows insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message) values (?,?,?,?,?,?,?) statement With this option you can pass your own statement if you don't want to you the options "table" and "columns". statement => "insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message)" ." values (?,?,?,?,?,?,?)" values With this option you have to set the values for the insert. values => "%level, %time, %date, %pid, %hostname, %progname, %message", # or values => [ qw/%level %time %date %pid %hostname %progname %message/ ], The placeholders are identical with the pattern names that you have to pass with the option "message_pattern" from Log::Handler. %L level %T time %D date %P pid %H hostname %N newline %C caller %p package %f filename %l line %s subroutine %S progname %r runtime %t mtime %m message Take a look to the documentation of Log::Handler for all possible patterns. persistent With this option you can enable or disable a persistent database connection and re-connect if the connection was lost. This option is set to 1 on default. dbi_params This option is useful if you want to pass arguments to DBI. The default is set to { PrintError => 0, AutoCommit => 1 } "PrintError" is deactivated because this would print error messages as warnings to STDERR. You can pass your own arguments - and overwrite it - with dbi_params => { PrintError => 1, AutoCommit => 0 } debug With this option it's possible to enable debugging. The information can be intercepted with $SIG{__WARN__}. log() Log a message to the database. my $db = Log::Handler::Output::DBI->new( database => "database", driver => "mysql", user => "user", password => "password", host => "127.0.0.1", port => 3306, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], persistent => 1, ); $db->log( message => "your message", level => "INFO", time => "2008-10-10 10:12:23", ); Or you can connect to the database yourself. You should notice that if the database connection lost then the logger can't re-connect to the database and would return an error. Use "dbi_handle" at your own risk. my $dbh = DBI->connect(...); my $db = Log::Handler::Output::DBI->new( dbi_handle => $dbh, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], ); connect() Connect to the database. disconnect() Disconnect from the database. validate() Validate a configuration. reload() Reload with a new configuration. errstr() This function returns the last error message. PREREQUISITES
Carp Params::Validate DBI your DBI driver you want to use EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Output::DBI(3pm)
All times are GMT -4. The time now is 05:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy