- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- batch file execution
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2010 11:24 PM
тАО01-19-2010 11:24 PM
batch file execution
I create a batch file and also create file is called FAIMOS for database.
The batch file is executed automatically at start-up ,so I want it to be executed ONLY when the du of the FAIMOS is ZERO.
What could I add to the batch file in order to meet my requirement?
I know only how to get the batch file executed at start-up.
bye.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2010 11:53 PM
тАО01-19-2010 11:53 PM
Re: batch file execution
Look for "-s".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 05:19 AM
тАО01-20-2010 05:19 AM
Re: batch file execution
I have two directories the first one is called faimos and it has some data,
and the other is called fiims and it is empty.
I made two batch files are called startup_1 and startup_2.
The first batch file (startup_1) is contained the following :-
-----------------------
vi startup_1
dir1=/faimos
if test -s "$dir1" then
echo the faimos directory has some data
fi
---------------------------
And the second batch file is contained the following :-
----------------------------
vi startup_2
dir2=/fiims
if test -s "$dir2" then
echo the faimos directory is empty
fi
------------------------------
the results when I executed the first and the second batch file are shown bellow:-
--------------------
sh startup_1
the faimos directory has some data
--------------------
sh startup_2
the faimos directory is empty
--------------------
I think the first result is true, but the second result is wrong the message should not be appeared because the fiims directory is empty and If statement return false.
please could you help me to solve my problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 06:10 AM
тАО01-20-2010 06:10 AM
Re: batch file execution
> problem?
Perhaps, if you first decide what it is.
> [...] create file is called FAIMOS [...]
> [...] two directories the first one is
> called faimos [...]
If it's a file, then "test -s" should work.
If it's a directory, then you may need to do
more work.
> [...] when the du of the FAIMOS is ZERO.
What, exactly, is the condition you wish to
test? "du" says zero, or no files in the
directory, or what?
urtx# mkdir empty_directory
urtx# du -k empty_directory
8 empty_directory
It's not easy to get "du" to say zero. Even
an empty directory occupies some disk space.
urtx# mkdir non-empty_directory
urtx# echo fred > non-empty_directory/small_file
urtx# ls -1A empty_directory
urtx# ls -1A non-empty_directory
small_file
urtx# ls -1A empty_directory | wc -l
0
urtx# ls -1A non-empty_directory | wc -l
1
urtx# find empty_directory
empty_directory
urtx# find non-empty_directory
non-empty_directory
non-empty_directory/small_file
"wc -l" could count those, too.
urtx# find empty_directory | grep '/'
urtx# echo $?
1
urtx# find non-empty_directory | grep '/'
non-empty_directory/small_file
urtx# echo $?
0
"grep -q" would be quieter:
urtx# find empty_directory | grep -q '/'
urtx# echo $?
1
urtx# find non-empty_directory | grep -q '/'
urtx# echo $?
0
As usual, many things are possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 06:20 AM
тАО01-20-2010 06:20 AM
Re: batch file execution
That works without a semi-colon? I'd say:
if test -s "$dir1"; then
dir1=/faimos
if test -s "$dir1" then
echo the faimos directory has some data
dir2=/fiims
if test -s "$dir2" then
echo the faimos directory is empty
This stuff is not magic. Changing the
message does not change the meaning of
"test -s". "test" does offer this:
! Unary negation operator.
and _that_ does work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 09:41 AM
тАО01-20-2010 09:41 AM
Re: batch file execution
The condition I wish to
test? "du" says zero in the
directory, pleas could you provide me with complete syntax for if statement.
Bye.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 11:16 AM
тАО01-20-2010 11:16 AM
Re: batch file execution
> test? "du" says zero in the
> directory
Are you not reading this stuff? As I've
showed, "du" does not say zero for an empty
directory. Does your "du" work differently
from mine?
> pleas could you provide me with complete
> syntax for if statement.
You're not paying me enough to get me to do
your whole job for you. I've already offered
a few different methods which should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 10:56 PM
тАО01-20-2010 10:56 PM
Re: batch file execution
You're not paying me enough to get me to do
your whole job for you.
The exact and the whole job I intend to do with described details is:-
I create a batch file is called at_startup and also create a directory is called Faimos for database.
The batch file is executed automatically at start-up and contains the following:-
vi at_startup
LOGFILE=/usr/backup/logfile; export LOGFILE
date >>$LOGFILE 2>>$LOGFILE
TAPE=/dev/ntape/tape0c
su - oracle -c /usr/backup/dbshut >>$LOGFILE 2>>$LOGFILE
cd /
tar -xvf $TAPE faimos
find /faimos -name '*.dump' -exec rm {} \;
su - oracle -c /usr/backup/dbstart >>$LOGFILE 2>>$LOGFILE
su - oracle -c "sqlplus system/manager @/alt_fa_user.sql"
but I need this batch file to be executed only when Faimos directory is empty
bye.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-20-2010 11:52 PM
тАО01-20-2010 11:52 PM
Re: batch file execution
> a few different methods which should work.
Still true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2010 11:44 PM
тАО01-23-2010 11:44 PM