- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script for SQL loader
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
тАО07-01-2004 02:35 AM
тАО07-01-2004 02:35 AM
The following code using a wildcard fails if no file exists. I'm hoping someone can have a look and help me fix this. As long as the file exists, the script works fine. If the file doesn't exist, it fails and aborts the process. We have tried piping it to NULL with no change. Any ideas?
Dave
# Date Created: 04/20/04
# Parameters:
# Data Directory - This is the UNIX folder where the data files will be loaded from.
# Archive Directory - This is the UNIX folder where archived files are created.
# Control File - Complete path to SQL*Loader Control file.
# Apps User - Applications Username.
# Apps Password - Applications Password.
#
#!/bin/sh
#echo 'Program Name :'$0
#echo 'username/pwd :' $1
#echo 'apps user id :' $2
#echo 'apps username:' $3
#echo 'request id :' $4
echo -------------------
echo 'Program arguments:'
echo -------------------
# your shellscript arguments start below :
v_timestamp=`date '+%Y%m%d%H%M%S'`
v_user_pwd=$1
v_data_dir=$5
v_archive_dir=$6
v_control_file=$7
v_file_mask=$8
echo "v_data_dir:" $v_data_dir
echo "v_archive_dir:" $v_archive_dir
echo "v_control_file:" $v_control_file
echo "v_file_mask:" $v_file_mask
cd $v_data_dir
for l_file in `ls -t $v_file_mask` - **This is the line that produces stderr output if there is no file matching the file mask 'MTL_CNV*'
do
echo $l_file
`/u02/oracle/prdora/8.0.6/bin/sqlload userid=$v_user_pwd control=$v_control_file data=$l_file log=$l_file.log bad=$l_file.bad`
echo 'SQL*Load complete'
if [[ -a $l_file.bad ]] then
echo "SQL*Loader produced a .bad file for $l_file"
else
for l_file_1 in `ls -t $l_file*`
do
mv $l_file_1 $v_archive_dir/$l_file_1
echo moved file $l_file_1 to $v_archive_dir
done
fi
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 02:47 AM
тАО07-01-2004 02:47 AM
SolutionIf you want to exit greacfully before entering the loop, just test if there're file in the folder.
Something like :
ls $v_data_dir/$v_file_mask 1>/dev/null 2>&1
[ $? -ne 0 ] && exit 0
Is that want you wanted ?
Cheers
Nicolas
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 02:50 AM
тАО07-01-2004 02:50 AM
Re: script for SQL loader
Count=`ls $v_data_dir/$v_file_mask 2>/dev/null |wc -l`
[ $Count -ne 0 ] && exit 0
(I'm not sure that ls will return an error if no file in your mask.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 02:56 AM
тАО07-01-2004 02:56 AM
Re: script for SQL loader
Thanks for the posts! Excuse my ignorance here but I need some help on the placement of your suggestions.
Would the location of your suggested changes go after the cd $v_data_dir and after the "for"?
I will award points after I have responses.
Thanks,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 03:06 AM
тАО07-01-2004 03:06 AM
Re: script for SQL loader
exit 0 may not be a good thing. You should maybe exit 1, so that unsuccessfull completion can be trapped by the script that launch this one... but a script is never achieved ;)
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2004 03:23 AM
тАО07-01-2004 03:23 AM
Re: script for SQL loader
Thanks for the help. It did indeed exit gracefully.
Fred,
I may mess around with the exit code 0 versus 1 but for now, it seems to complete okay. I appreciate the assistance.
Dave