Sponsored Content
Top Forums Shell Programming and Scripting Outputting Errors to a Log file Post 303013085 by Stellaman1977 on Wednesday 14th of February 2018 02:26:27 PM
Old 02-14-2018
Quote:
Originally Posted by jim mcnamara
printf does not open and print a file you want cat

Code:
cp -R /dir/dir/dir /dir2/dir2/dir2 2>&1 || cat /dir/dir/logfile

This only displays logfile when there is an error, which I guess is what you want. Note the double pipe.
Thanks. Just to be clear, I don't want to display the log file. I want the existing log file (text document) to record any errors that happened during copying. Does this do that? Also, why the double pipe? This means do the second command if the first failed- correct? What are the two commands?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in outputting the result in log files

This is the file am having: "40","1G1AL55 ",30482,9000 "40","1G1ZT58 ",29098,10600 "40","1G1AL15 ",29222,9400 "46","1G6KD57 ",3083,28400 "46","1G6KD57 ",27909,25200 "49","1G1ZU57 ",16391,13900 "49","1G2ZG58 ",28856,12400 I want to display the output in three files... (23 Replies)
Discussion started by: dave_nithis
23 Replies

2. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

3. Shell Programming and Scripting

redirect errors to log file

I am working on a generic script that will run a shell script with the arguments passed and redirect errors to one file, and all other output to another file. Then if there is anything in the error file it emails the error to me, otherwise it exits. The advantage for this approach is that I... (0 Replies)
Discussion started by: gandolf989
0 Replies

4. Shell Programming and Scripting

simple count script outputting mass errors

script outputting cant find anything wrong with the script either... : #!/bin/sh #count execution script time=0 while do if then time=`expr $time + 1` if then echo "The current tick is 100" fi fi (2 Replies)
Discussion started by: aspect_p
2 Replies

5. Shell Programming and Scripting

prevent errors/warnings from being written to log file

i have this script which works fine but shows errors when it runs..these are more like warnings and the script runs fine.. i am on a sun machine.. i know it writes all the error messages to a master log file.. is there any way i can turn off these warnings/error messages and prevent them from being... (2 Replies)
Discussion started by: npatwardhan
2 Replies

6. Shell Programming and Scripting

track the errors in log file

OS: SuSE Linux Enterprise Server 10 Goal: To track the errors in log file, If they exits users will be notify by email. We have a script below: SrchKey="SRVE0242I:" LogFile=/PATHtemOut.log MailTo="DN@mail.com http:// ! -f PATH/alert.last && touch PATH/alert.last egrep $SrchKey $LogFile... (3 Replies)
Discussion started by: sdhn1900
3 Replies

7. Shell Programming and Scripting

Capturing errors messages into log file

Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file? If yes, can anyone please let me know on how to do it? I am using ksh and working on AIX server. Thank you in advance. (4 Replies)
Discussion started by: vpv0002
4 Replies

8. Shell Programming and Scripting

Finding errors in log file only in last 10 minutes

Hi there, I have a log file that I need to check every 10 minutes to find if a specific error exists but only in that 10 minute period. The reason is that the log is quite large, and will frequently contain these errors, so I only want alerting if it in the last 10 minutes - I don't want... (3 Replies)
Discussion started by: paul_vf
3 Replies

9. Shell Programming and Scripting

Scan log file for errors

Hi everyone. I am still new to UNIX, and am having trouble figuring out how to create a script to scan a log file to look for errors based on a string. We run AIX 5.3, and would like the ability to report all the instances of WebSphere Broker Execution groups crashing. This script would... (8 Replies)
Discussion started by: jimbojames
8 Replies

10. Shell Programming and Scripting

Outputting data from log file to report

I have a log file that looks like this. the lines are grouped. 2 lines per entry. M: 2019-01-25 13:02:31.698 P25, received network transmission from KI4EKI to TG 10282 M: 2019-01-25 13:02:35.694 P25, network end of transmission, 4.3 seconds, 1% packet loss M: 2019-01-25 13:02:38.893 P25,... (7 Replies)
Discussion started by: ae4ml
7 Replies
CHECKBASHISMS(1)					      General Commands Manual						  CHECKBASHISMS(1)

NAME
checkbashisms - check for bashisms in /bin/sh scripts SYNOPSIS
checkbashisms script ... checkbashisms --help|--version DESCRIPTION
checkbashisms, based on one of the checks from the lintian system, performs basic checks on /bin/sh shell scripts for the possible presence of bashisms. It takes the names of the shell scripts on the command line, and outputs warnings if possible bashisms are detected. Note that the definition of a bashism in this context roughly equates to "a shell feature that is not required to be supported by POSIX"; this means that some issues flagged may be permitted under optional sections of POSIX, such as XSI or User Portability. In cases where POSIX and Debian Policy disagree, checkbashisms by default allows extensions permitted by Policy but may also provide options for stricter checking. OPTIONS
--help, -h Show a summary of options. --newline, -n Check for "echo -n" usage (non POSIX but required by Debian Policy 10.4.) --posix, -p Check for issues which are non POSIX but required to be supported by Debian Policy 10.4 (implies -n). --force, -f Force each script to be checked, even if it would normally not be (for instance, it has a bash or non POSIX shell shebang or appears to be a shell wrapper). --extra, -x Highlight lines which, whilst they do not contain bashisms, may be useful in determining whether a particular issue is a false posi- tive which may be ignored. For example, the use of "$BASH_ENV" may be preceded by checking whether "$BASH" is set. --version, -v Show version and copyright information. EXIT VALUES
The exit value will be 0 if no possible bashisms or other problems were detected. Otherwise it will be the sum of the following error val- ues: 1 A possible bashism was detected. 2 A file was skipped for some reason, for example, because it was unreadable or not found. The warning message will give details. SEE ALSO
lintian(1). AUTHOR
checkbashisms was originally written as a shell script by Yann Dirson <dirson@debian.org> and rewritten in Perl with many more features by Julian Gilbey <jdg@debian.org>. DEBIAN
Debian Utilities CHECKBASHISMS(1)
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy