The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Setting environment variable on a remote solaris machine using shell script eamani_sun Shell Programming and Scripting 1 05-30-2008 10:05 PM
setting a global variable in script arunkumar_mca UNIX for Dummies Questions & Answers 3 10-23-2007 07:46 AM
Variable setting help please penfold Shell Programming and Scripting 16 03-25-2006 09:25 PM
Simply shell script question frustrated1 Shell Programming and Scripting 8 07-03-2005 02:22 AM
Setting a variable photh UNIX for Dummies Questions & Answers 2 01-08-2003 10:03 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-12-2007
liketheshell liketheshell is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 21
Setting basename and dirname variable to simply script.

Hello all,

Can somebody explain to me how set up a basename and dirname variable to simplify this script. I currently have a 'infile' with the contents of FTTPDataPVC_ & BaaisDSLFeed. I need to add a basename and or dirname variable so that any additions can be made through the infile and not really have to modify the script itself. I'm kinda in a crunch, so your help is greatly appreciated. If you can offer any suggestions on how to make this work or a better solution in handling the script will really help.


#Here is my script


alertUser="johndoe@yahoo.com"
now=`date '+%m%d%y'`.txt
now2=`date '+%m%d%Y'`.txt
#BAAIS_MAIL=/apps/opt/tmp/baaisMFile

for i in `cat /apps/opt/tmp/baaisFile`
do

file=$(echo "${i}$now" | grep 'FTTPDataPVC_')

file2=$(echo ${i}$now2 | grep 'BaaisDSLFeed.')


if [[ -f /apps/opt/Batch/inbox/"${file}" ]] || [[ -f /apps/opt/BatchFeed/inbox/"${file2}" ]]
then
echo "${file} ${file2} file found"

else


echo "${file} ${file2} not found\c Please contact Production Support" >> /apps/opt/tmp/baaisMFile


fi

done

cat "/apps/opt/tmp/baaisMFile" | mailx -s "Alert: $(hostname) Baais File not Found" $alertUser

#rm -r /apps/opt/tmp/baaisMFile

Thanks,

AC
  #2 (permalink)  
Old 09-12-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by liketheshell View Post
cat "/apps/opt/tmp/baaisMFile" | mailx -s "Alert: $(hostname) Baais File not Found" $alertUser
1. Did you intend ${hostname} ?

2. Personally I have all variables upper-case to make them obvious.

3. Try..

Code:
DIRNAME=`dirname $SOMEFILE`
BASENAME=`basename $SOMEFILE`
echo $BASENAME is in $DIRNAME
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0