Sponsored Content
Full Discussion: Trap explanation?
Top Forums UNIX for Beginners Questions & Answers Trap explanation? Post 303004479 by cero on Tuesday 3rd of October 2017 07:28:18 AM
Old 10-03-2017
Hi,

test -s checks if the file exists and its size is greater than zero.
So if the file exists but is empty it will be removed.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Building a better mouse trap, or How many lines of code does it take to trap a mouse?

Hello all, I'm hoping to get a little insight from some of the wily veterans amongst you. I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to... (4 Replies)
Discussion started by: mph
4 Replies

2. Shell Programming and Scripting

tr explanation please

how does below tr command replace nonletters with newlines? I think I understand tr -cs '\n' part.. but what is A-Za-z\' <--- what is this?? tr -cs A-Za-z\' '\n' | -c --complement -s, --squeeze-repeats replace each input sequence of a repeated character that is... (0 Replies)
Discussion started by: convenientstore
0 Replies

3. Shell Programming and Scripting

tr explanation please

how does below tr command replace nonletters with newlines? I think I understand tr -cs '\n' part.. but what is A-Za-z\' <--- what is this?? tr -cs A-Za-z\' '\n' | -c --complement -s, --squeeze-repeats replace each input sequence of a repeated character that is... (1 Reply)
Discussion started by: convenientstore
1 Replies

4. UNIX for Advanced & Expert Users

Need help with trap

Hi Our problem is knowing: What is the "best" way of simulating a TRAP for ERR within a function, since we know this will not work directly with ksh93 and aix5. How can we save the error encountered in the function and then deal with it in the calling script? Thanks! (3 Replies)
Discussion started by: theteeth07
3 Replies

5. UNIX and Linux Applications

need explanation

Hi am having a c pgm. It has the include files (unistd.h,sys/types.h,win.h,scr.h,curses.h,stdarg.h and color.h). I don't know the purpose of these include files. will u plz explain me. (1 Reply)
Discussion started by: Mari.kb
1 Replies

6. Shell Programming and Scripting

How to trap

I have a script #!/bin/ksh trap cleanup 20 cleanup() { cat $t.log echo Caught exit 1 } if ;then echo Found >>t.log exit 20 else echo Not found >>t.log exit 20 fi (5 Replies)
Discussion started by: thana
5 Replies

7. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

8. UNIX for Dummies Questions & Answers

In need of explanation

Its great someone provided this script that strips out a filename and extension but can someone explain how each line works? file1='Jane Mid Doe.txt' newfile='Jane.txt' 1) ext=${file1##*.} 2) filename=${file%%.???} 3) set -- $filename 4) newfile="1.$extension" (1 Reply)
Discussion started by: Lillyt
1 Replies

9. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

10. Shell Programming and Scripting

Need explanation

Hi, I need more explination on it, how it works abcd="$(echo "$abcd" | sed 's/ //g')" >> ${LOGFILE} 2>&1 can any one suggest me on this? Rgds, LKR (1 Reply)
Discussion started by: lakshmanraok
1 Replies
Test::Trap::Builder::SystemSafe(3)			User Contributed Perl Documentation			Test::Trap::Builder::SystemSafe(3)

NAME
Test::Trap::Builder::SystemSafe - "Safe" output layer backend using File::Temp VERSION
Version 0.2.3 DESCRIPTION
This module provides an implementation systemsafe, based on File::Temp, for the trap's output layers. This implementation insists on reopening the output file handles with the same descriptors, and therefore, unlike Test::Trap::Builder::TempFile and Test::Trap::Builder::PerlIO, is able to trap output from forked-off processes, including system(). See also Test::Trap (:stdout and :stderr) and Test::Trap::Builder (output_layer). CAVEATS
Using File::Temp, we need privileges to create tempfiles. We need disk space for the output of every trap (it should clean up after the trap is sprung). Disk access may be slow -- certainly compared to the in-memory files of PerlIO. If the file handle we try to trap using this backend is on an in-memory file, it would not be available to other processes in any case. Rather than change the semantics of the trapped code or silently fail to trap output from forked-off processes, we just raise an exception in this case. If there is another file handle with the same descriptor (f ex after an "open OTHER, '>&=', THIS"), we can't get that file descriptor. Rather than silently fail, we again raise an exception. Threads? No idea. It might even work correctly. BUGS
Please report any bugs or feature requests directly to the author. AUTHOR
Eirik Berg Hanssen, "<ebhanssen@allverden.no>" COPYRIGHT &; LICENSE Copyright 2006-2012 Eirik Berg Hanssen, 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.18.2 2017-10-06 Test::Trap::Builder::SystemSafe(3)
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy