04-16-2010
Silly question - how does the "mv" command work?
I know this may sound really elemental, but I'm trying to figure out if I'm correct.
I have a script that moves a file from a temp directory to (what I am calling) a pickup directory.
On another machine, I have this "other program" that scans the contents of the pickup directory for a specific file name. If the file name exists, the program goes forth and does a bunch of routines ... (really not plausible to my question)
However, I have a feeling that this "other program" is grabbing this file too soon as the "mv" hasn't successfully completed writing the files contents; perhaps just the filename.
I did a test on the "other program" and the scan looks for the said file (in a while loop) approx. 22,000 within 10 seconds (a timeout).
The size of the "moved" file varies but is averages at about 200-300 bytes.
Can someone tell me if the move command first creates the file then writes?
Thank you!
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi there
I'm logged in as root on a UNIX Spark 10 using a SSH client.
I notice that the time on the machine is wrong and I type "man date" in order to receive the options how to change this.
When typing "man date" and hitting Enter I get the message "No manual entry for date"
Why? Am I... (1 Reply)
Discussion started by: aptit
1 Replies
2. Shell Programming and Scripting
Hi guy,
I have a problem to pass a variable containing '*' value to FIND command.
below is the script. It doesn't work by submit below command:
rmf.sh name '*.txt'
or
rmf.sh name *.txt
I've tried either optn="-name '$2'" or optn="-name $2"., and there is no luck.
### (script... (5 Replies)
Discussion started by: unxuser
5 Replies
3. UNIX for Advanced & Expert Users
when i give "ps -elf" or "ps" system gets hung.
if i press "^c" come out from it...
pls help..what should i do to get it resolved.
thanks
CKanth (4 Replies)
Discussion started by: srikanthus2002
4 Replies
4. AIX
When I use "/" to look for a particular command that I typed in the current session it says
D02:-/home/user1/temp> /job
ksh: /job: not found.
D02:-/home/user1/temp>
previously it used to fetch all the commands which had job in it..
for example subjob, endjob, joblist etc...
may I... (7 Replies)
Discussion started by: meetzap
7 Replies
5. Shell Programming and Scripting
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Discussion started by: shis100
7 Replies
6. UNIX for Dummies Questions & Answers
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
7. Red Hat
Dear Concern,
We have observed that following command stuck/does not work in some RedHat nodes. Please advise us to troubleshoot the issue.
/usr/sbin/hpacucli ctrl all show
Note: HP Array Configuration Utility CLI for Linux 64-bit
With Best Regards,
Md. Abdullah-Al Kauser (3 Replies)
Discussion started by: makauser
3 Replies
8. UNIX for Beginners Questions & Answers
Hi there, this may be a beginner's error, but I've been unable to find a solution on my own and by googling, and now I am really stuck on it.
I am simply trying to move directories called for example CAT_Run01.ica to a directory with the corresponding number, Run01, in the same directory.
For... (2 Replies)
Discussion started by: andrevol
2 Replies
LEARN ABOUT OSX
sub::quote
Sub::Quote(3) User Contributed Perl Documentation Sub::Quote(3)
NAME
Sub::Quote - efficient generation of subroutines via string eval
SYNOPSIS
package Silly;
use Sub::Quote qw(quote_sub unquote_sub quoted_from_sub);
quote_sub 'Silly::kitty', q{ print "meow" };
quote_sub 'Silly::doggy', q{ print "woof" };
my $sound = 0;
quote_sub 'Silly::dagron',
q{ print ++$sound % 2 ? 'burninate' : 'roar' },
{ '$sound' => $sound };
And elsewhere:
Silly->kitty; # meow
Silly->doggy; # woof
Silly->dagron; # burninate
Silly->dagron; # roar
Silly->dagron; # burninate
DESCRIPTION
This package provides performant ways to generate subroutines from strings.
SUBROUTINES
quote_sub
my $coderef = quote_sub 'Foo::bar', q{ print $x++ . "
" }, { '$x' => };
Arguments: ?$name, $code, ?\%captures, ?\%options
$name is the subroutine where the coderef will be installed.
$code is a string that will be turned into code.
"\%captures" is a hashref of variables that will be made available to the code. See the "SYNOPSIS"'s "Silly::dagron" for an example using
captures.
options
o no_install
Boolean. Set this option to not install the generated coderef into the passed subroutine name on undefer.
unquote_sub
my $coderef = unquote_sub $sub;
Forcibly replace subroutine with actual code. Note that for performance reasons all quoted subs declared so far will be globally
unquoted/parsed in a single eval. This means that if you have a syntax error in one of your quoted subs you may find out when some other
sub is unquoted.
If $sub is not a quoted sub, this is a no-op.
quoted_from_sub
my $data = quoted_from_sub $sub;
my ($name, $code, $captures, $compiled_sub) = @$data;
Returns original arguments to quote_sub, plus the compiled version if this sub has already been unquoted.
Note that $sub can be either the original quoted version or the compiled version for convenience.
inlinify
my $prelude = capture_unroll {
'$x' => 1,
'$y' => 2,
};
my $inlined_code = inlinify q{
my ($x, $y) = @_;
print $x + $y . "
";
}, '$x, $y', $prelude;
Takes a string of code, a string of arguments, a string of code which acts as a "prelude", and a Boolean representing whether or not to
localize the arguments.
capture_unroll
my $prelude = capture_unroll {
'$x' => 1,
'$y' => 2,
};
Generates a snippet of code which is suitable to be used as a prelude for "inlinify". The keys are the names of the variables and the
values are (duh) the values. Note that references work as values.
CAVEATS
Much of this is just string-based code-generation, and as a result, a few caveats apply.
return
Calling "return" from a quote_sub'ed sub will not likely do what you intend. Instead of returning from the code you defined in
"quote_sub", it will return from the overall function it is composited into.
So when you pass in:
quote_sub q{ return 1 if $condition; $morecode }
It might turn up in the intended context as follows:
sub foo {
<important code a>
do {
return 1 if $condition;
$morecode
};
<important code b>
}
Which will obviously return from foo, when all you meant to do was return from the code context in quote_sub and proceed with running
important code b.
perl v5.16.2 2012-07-04 Sub::Quote(3)