Sponsored Content
Full Discussion: Alternate to copy + remove
Top Forums Shell Programming and Scripting Alternate to copy + remove Post 302957538 by Don Cragun on Monday 12th of October 2015 02:23:49 PM
Old 10-12-2015
Note, however, that you have a built-in race condition...
If someone opens file1 for appending during the cp and then writes to that file descriptor:
  • the data may be copied into fie2 by the cp,
  • may be cleared by the > /dev/null never to be seen again,
  • or may appear in file1 after it has been cleared by the > /dev/null.
To get rid of this race condition, we need to know more about how processes writing to file1 open the file and how the permissions of processes writing to that file are related to the owner and group of the directory in which the target file resides.

The writers obviously have write permission to the target file. If they also have write permission in the directory in which it resides, the safe thing would be to use:
Code:
mv file1 file2

and have the writers open file1 with the flags:
Code:
fd = open("file1", O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);

guaranteeing (assuming no write errors) that data written to that file descriptor will appear either in file1 or file2.

If you can't do that; you need to block all writers to file1 while it is being rotated.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Files then with option of remove

hi, i encounter a quite a new things for me. lets sat my test.txt modified date is 6th of July 2005. then i execute the following command: "cp test.txt testfolder/test.txt" when i go to execute "ls -l" command... the test.txt modified date become today date! but if i execute: ... (5 Replies)
Discussion started by: maldini
5 Replies

2. HP-UX

How to remove alternate boot disk (vg00) in mirror

How do we remove mirror (vg00) in itanium system having 11.23 version. (2 Replies)
Discussion started by: jeelans
2 Replies

3. UNIX for Dummies Questions & Answers

Copy all the files with time stamp and remove header,trailer from file

All, I am new to unix and i have the following requirement. I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file.. Could... (35 Replies)
Discussion started by: ksrams
35 Replies

4. Shell Programming and Scripting

Alternate way for echo.

Hi, Is there any other command echo does. if I am doing this operation for each line in my file. So its taking very long time to process more than 1000 records. Is there any alternative way to write the above if statement (5 Replies)
Discussion started by: senthil_is
5 Replies

5. Shell Programming and Scripting

alternate lines

Hi, I'm new to Unix. I want to read the all the lines from a text file and write the alternate lines into another file. Please give me a shell script solution. file1 ----- one two three four five six seven newfile(it should contain the alternate lines from the file1) ------- one... (6 Replies)
Discussion started by: pstanand
6 Replies

6. UNIX for Dummies Questions & Answers

copy all files and folders and cjange or remove ownership

So tried: cp -r -p test1/ user@machine:///srv/www/vhosts/domain.co.uk/httpdocs/backup/ but this didn't work either :( Anyone able to help with this? Many thanks Mr M (3 Replies)
Discussion started by: misterm
3 Replies

7. Solaris

Self ssl alternate in Solaris

Instead of using an external Certification Authority CA such as Verisgn, in windows I have been told there is something called self ssl ( The server is its own Certification Authority) In Solaris is there such an alternate? In need it for apache. Much appreciate for any guidence. Thanks (2 Replies)
Discussion started by: Tirmazi
2 Replies

8. UNIX for Dummies Questions & Answers

how to copy a file without remove the contents of the target file?

Hello every body, Kindly support me to "copy a file without remove the contents of the target file" Thanks in advance. :) Ahmed Amer Cairo,Egypt (2 Replies)
Discussion started by: ahmedamer12
2 Replies

9. HP-UX

Alternate for wget

Hi, Whats the alternate for wget in HP-UX ? (4 Replies)
Discussion started by: mohtashims
4 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 02:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy