09-12-2007
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
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
I know to set global variable i can use export .. But take the situation like below ..
I want to set a variable in one script and access that in second script
i have done like this .. It is not working
one.sh
#!/usr/bin/ksh
echo $RISSHI
export RISSHI=1
two.sh... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies
2. Shell Programming and Scripting
Hi guys, last cry for help for today. I appreciate the help so far.
ok so I have a program that dumps a path into my script as a variable ($1)
This path is an example
/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3
So in order to search thetvdb.com for a show, I need to extract... (6 Replies)
Discussion started by: tret
6 Replies
3. Programming
Hi
I faced with some interesting behavior of basename and dirname functions from libgen.h: they changes the value of argument! Here is the declaration:
char *basename(char *);
char *dirname(char *);It makes some tiresome to use them... I am new to C and maybe I do something wrong, but to... (4 Replies)
Discussion started by: Sapfeer
4 Replies
4. Shell Programming and Scripting
Hi All,
I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies
5. Shell Programming and Scripting
Hello Everyone,
I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following:
* I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Discussion started by: jimmy75_13
13 Replies
6. Shell Programming and Scripting
The following is part of a larger shell script
grep -v "Col1" my_test.log | grep -v "-" | awk '$5 == "Y" {print $1}'
instead of printing, can I set set $1 to a variable that the rest of the shell script can read?
if $5 == Y, I want to call another shell script and pass $1 as a... (2 Replies)
Discussion started by: guessingo
2 Replies
7. UNIX for Advanced & Expert Users
Is there anyway in which i can set a permanent global variable in unix, which when initialised with a value and modified during any shell script, would retain its value even if i logout and login
I dont know whether i am being able to express my need clearly but basically what i want is a... (3 Replies)
Discussion started by: arindamlive
3 Replies
8. Shell Programming and Scripting
Hello all,
I know this must be simple .... but i can't grasp what could be the issue.
I'm trying to setup the timezone variable (to the unix command date) according to what i find in a value that i got from parsing the config file.
The end result would be setting the log file with this new... (4 Replies)
Discussion started by: maverick72
4 Replies
9. Programming
hi all,
trying to get this to work but im struggling abit and wondered if you can help me out
basically i have created a variable
base='basename $dir'
echo "please specify full path to directory you want to be made into a tar"
read -e dir
tar -cf... (7 Replies)
Discussion started by: robertkwild
7 Replies
10. Shell Programming and Scripting
This is a two part request for an assistance.
I am not sure how retrieve value from basename command - line 270 -so in can be output as variable CLI_COMMAND - line 250 in whiptail input box.
As coded I can input from keyboard ( stdin?) into input box using redirection.
I can... (2 Replies)
Discussion started by: annacreek
2 Replies