Sponsored Content
Top Forums Shell Programming and Scripting [Shell/Perl(?)] Prepending timestamps to console output & writing results to a file Post 302647007 by agama on Saturday 26th of May 2012 05:41:15 PM
Old 05-26-2012
Can you not just pipe it through your perl programme on the way to the output file? Using awk (I don't do perl) it'd be something like this:

Code:
${DSMPath} -id=${TivUser} -password=${TivPassword} -console 2>&1 | awk 'BEGIN { c = "date \"+%D %T\""; } { m=$0; c | getline; close( c ); print $0, m; }' >output &



Test with a simple construct:

Code:
ps -elf | awk 'BEGIN { c = "date \"+%D %T\""; } { m=$0; c | getline; close( c ); print $0, m; }' >output &



This will execute quickly enough that I'd expect all timestamps to have the same value, but you'll see that it works.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding pattern & prepending a line with text

Hello Dudes, I have a task to make a unix shell script that should search for a specific TEXT in a file.If that TEXT is found, shell script should add a comment statement before that TEXT line. Ex : LINE 1 xxxxx LINE 2 xxxx CALL xxxx LINE 3 xxxx PERFORM UNTIL if i... (1 Reply)
Discussion started by: kirrushna
1 Replies

2. UNIX for Dummies Questions & Answers

Writing to a file without echo it to the console !!!!

hi all, I am trying to write some message to a file using the following command. echo "${MESSAGE}" >&1 | tee -a ${File_name} can the same be done without using echo . I don't want the result to be displayed to the console. Can anyone guide me. Thanks in advance (6 Replies)
Discussion started by: amit_kv1983
6 Replies

3. Shell Programming and Scripting

Writing sql results to file using ksh -nevermind

I'm having problems with writing my sql results to a file: sqlplus -S username/password@DB <<!! set echo off set verify off set showmode off set feedback off set timing off set linesize 250 set wrap off set pagesize 0 set newpage none set tab off set trimspool on set colsep... (1 Reply)
Discussion started by: avillanueva
1 Replies

4. Shell Programming and Scripting

shell script output in HTML or with table like results

Hello, Currently i have a ksh script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html or excel format and send that content as email. Please help me how i can do... (2 Replies)
Discussion started by: kotasateesh
2 Replies

5. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

6. Shell Programming and Scripting

Perl - save results to output file.

Can any one please help, the code works...I want the output of $result to be saved in an output.txt file which is lcoated in c:\\temp\\output.txt. $filepath="C:\\temp\\ip.txt"; open (HOSTLIST,"$filepath"); @hosts=(<HOSTLIST>); foreach $host(@hosts) { $results = `nslookup... (1 Reply)
Discussion started by: sureshcisco
1 Replies

7. Shell Programming and Scripting

Sed script for appending & prepending

Hello Mates I am trying to write a script, which appends and prepends the text in a file. I tried testing with a small file and it worked fine. but for the large file, the script is wiping the entire file and adds only the word to be appended in the file. mv $file_name $file_name.bak sed... (6 Replies)
Discussion started by: sathyaac
6 Replies

8. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

9. Shell Programming and Scripting

[Solved] Writing output to the console

Hi All, I have written one script in which am writting the result to the log file. I want to display the results on the console also if ; then echo "$result doesnot match with the host file">>InputHostsFileErrors.txt else echo "$result input matches with the host... (7 Replies)
Discussion started by: sharsour
7 Replies

10. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies
setupcon(1)							   User Manuals 						       setupcon(1)

NAME
setupcon - sets up the font and the keyboard on Linux console SYNOPSIS
setupcon [ option ]... [ variant ... ] DESCRIPTION
setupcon is a program for fast and easy setup of the font and the keyboard on the Linux console. OPTIONS
-k, --keyboard-only Setup the keyboard only, do not setup the font. -f, --font-only Setup the font only, do not setup the keyboard. --force Do not check whether we are on the console. Notice that you can be forced to hard-reboot your computer if you run setupcon with this option and you are on a X server. -v, --verbose Be more verbose. Use this option if something goes wrong. --save If you want to use setupcon early in the boot process, it is possible that /usr is not yet mounted and the required data are not available. This option makes setupcon copy the required data in /etc/console-setup in order to make it available before /usr is mounted. If you use setupcon early in the boot process, then use this option whenever you change the console configuration. --save-only Same like --save, but do not setup the keyboard and the font. This option can be useful if you run setupcon in a X server. -h, --help Display usage information. variant Specifies which configuration file to use. By default the configuration file of setupcon is /etc/default/console-setup but if you use e.g. "chukchi" as variant then the configuration file will be /etc/default/console-setup.chukchi. This allows you to have sev- eral different configurations - for example one for the Chukchi language and another in /etc/default/console-setup for your default configuration. BASIC USAGE
Most of the time you invoke setupcon without arguments. Please look at the README file for more information. AUTHOR
Anton Zinoviev <anton@lml.bas.bg>, <zinoviev@debian.org> console-setup APR 2007 setupcon(1)
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy