02-04-2008
unix script to check the file size
please tell me in my case how i can modify the code
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We have data files that are ftp'd every morning to a SUN server. The file names are exactly the same except for that each has the date included in its name. I have to write script to do 2 things:
STEP 1) Verify that the file arrived in morning.
STEP 2) Compare the file size of the current... (3 Replies)
Discussion started by: rbknisely
3 Replies
2. Shell Programming and Scripting
So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following.
Search all the applications subdirectories for message.jar.
If the message.jar file exists, I need to search the application directory for... (1 Reply)
Discussion started by: mmdawg
1 Replies
3. Shell Programming and Scripting
Please could anyone provide me the Command/script to find the size and usage of Unix box ASAP ? (6 Replies)
Discussion started by: sakthifire
6 Replies
4. UNIX for Advanced & Expert Users
Anybody can help
HOW TO FIND THE FILE SIZE IN UNIX (5 Replies)
Discussion started by: lmraochodisetti
5 Replies
5. Shell Programming and Scripting
Hi All,
working on AIX 5.3.
Requirement is:
Shell script in ksh to check if any file exists in 4 folders as below:
1. /FILE/INB/INT1
2. /FILE/INB/INT2
3. /FILE/INB/INT3
4. /FILE/INB/INT4
Thanks a lot for your time!
a1_win. (3 Replies)
Discussion started by: a1_win
3 Replies
6. Shell Programming and Scripting
guys,
I am trying to write a script that does the following:
it looks for a file in a specific directory and if the file is not there (NOT), it emails me. I have tried the following but its not working. It simply hangs up. Please help.
if
then
mail -s 'blah blah blah' my email... (4 Replies)
Discussion started by: basisvasis
4 Replies
7. Shell Programming and Scripting
Hi,
I am looking for a shell script with the following.
1. It should check whether a particular file exists in a location
#!/bin/sh
if ;
then
echo "xxx.txt File Exists"
else
echo "File Not Found"
fi
2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies
8. Shell Programming and Scripting
Hi,
I am trying to write a script which checks if any file exists with "*.log" or "*.out" in Directory
below is the code
#------------------
path=/abd/xyz/
if ; then
echo "Good"
else
echo "Failure"
fi
#--------------------------
its always going to else part and printing... (8 Replies)
Discussion started by: ch33ry
8 Replies
9. Shell Programming and Scripting
Dear members, The following expect script connects to remote node and check for the file "authorized_keys" in directory /root/.ssh in remote node. However the result is always found even if the file exist or doesn't exist.
expect {
"$fname" {
send_user "found\n"
}
Any idea what is... (4 Replies)
Discussion started by: Sudhakar333
4 Replies
10. Shell Programming and Scripting
Hi All,
I am a beginner in this and trying to write a shell script in linux which will :
1. Ask for a file name and check if its exists.
2. If file exists only then it will ask for the new target folder, after entering target folder name it will check if it exists.
3. If target folder... (3 Replies)
Discussion started by: ashish_neekhra
3 Replies
LEARN ABOUT MOJAVE
context::preserve
Context::Preserve(3) User Contributed Perl Documentation Context::Preserve(3)
NAME
Context::Preserve - run code after a subroutine call, preserving the context the subroutine would have seen if it were the last statement
in the caller
SYNOPSIS
Have you ever written this?
my ($result, @result);
# run a sub in the correct context
if(!defined wantarray){
some::code();
}
elsif(wantarray){
@result = some::code();
}
else {
$result = some::code();
}
# do something after some::code
$_ += 42 for (@result, $result);
# finally return the correct value
if(!defined wantarray){
return;
}
elsif(wantarray){
return @result;
}
else {
return $result;
}
Now you can just write this instead:
use Context::Preserve;
return preserve_context { some::code() }
after => sub { $_ += 42 for @_ };
DESCRIPTION
Sometimes you need to call a function, get the results, act on the results, then return the result of the function. This is painful
because of contexts; the original function can behave different if it's called in void, scalar, or list context. You can ignore the
various cases and just pick one, but that's fragile. To do things right, you need to see which case you're being called in, and then call
the function in that context. This results in 3 code paths, which is a pain to type in (and maintain).
This module automates the process. You provide a coderef that is the "original function", and another coderef to run after the original
runs. You can modify the return value (aliased to @_) here, and do whatever else you need to do. "wantarray" is correct inside both
coderefs; in "after", though, the return value is ignored and the value "wantarray" returns is related to the context that the original
function was called in.
EXPORT
"preserve_context"
FUNCTIONS
preserve_context { original } [after|replace] => sub { after }
Invokes "original" in the same context as "preserve_context" was called in, save the results, runs "after" in the same context, then
returns the result of "original" (or "after" if "replace" is used).
If the second argument is "after", then you can modify @_ to affect the return value. "after"'s return value is ignored.
If the second argument is "replace", then modifying @_ doesn't do anything. The return value of "after" is returned from
"preserve_context" instead.
Run "preserve_context" like this:
sub whatever {
...
return preserve_context { orginal_function() }
after => sub { modify @_ };
}
or
sub whatever {
...
return preserve_context { orginal_function() }
replace => sub { return @new_return };
}
Note that there's no comma between the first block and the "after =>" part. This is how perl parses functions with the "(&@)" prototype.
The alternative is to say:
preserve_context(sub { original }, after => sub { after });
You can pick the one you like, but I think the first version is much prettier.
AUTHOR AND COPYRIGHT
Jonathan Rockway "<jrockway@cpan.org>"
Copyright (c) 2008 Infinity Interactive. You may redistribute this module under the same terms as Perl itself.
perl v5.18.2 2008-01-15 Context::Preserve(3)