- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Need Help On Script
Operating System - Linux
1754976
Members
3328
Online
108828
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО12-01-2005 03:37 PM
тАО12-01-2005 03:37 PM
Need Help On Script
Hi guys,
I developed script contains i have some files like IMExxxxx and IMFxxxxx in /home/abc/test folder,
if it start IME it will go to IME Loop and for IMF will go to IMF Loop
if it goes to IME loop then after i want to find string IMCT and GWAY in IME Files
But i developed but it going on first loop only i.e IME Loop only
script is given below
#!/usr/bin/sh
export DIRECTORY=/home/abc/test
export DATETIME=`date +"%y%m%d%S"`
export IME=test_ime
export GSE=test_gse
export IMF=test_imf
export GWY=test_gwy
export TMP=tmp
for file in $( find $DIRECTORY -type f -name '*.*' | sort )
do
FNAME=`echo ${file} |cut -c 16-18`
echo $FNAME
STNG=$(awk '(NR==2) { print substr($0,34,4); }' ${file})
if [ $FNAME==IME ]
then
echo $STNG"hi"
if [ $STNG=="IMCT" ]
then
echo $STNG"IMCT Loop"
mv ${WRKFILE} ${DIRECTORY}/${IME}
elif [ $STNG==GWAY ]
then
echo $STNG"GWAY Loop"
mv ${WRKFILE} ${DIRECTORY}/${GWY}
fi
elif [ $FNAME==IMF ]
then
echo $FNAME"IMF Loop"
mv ${WRKFILE} ${DIRECTORY}/${IMF}
else
mv ${DIRECTORY}/${WRKFILE} ${DIRECTORY}/${GSE}
fi
done
I developed script contains i have some files like IMExxxxx and IMFxxxxx in /home/abc/test folder,
if it start IME it will go to IME Loop and for IMF will go to IMF Loop
if it goes to IME loop then after i want to find string IMCT and GWAY in IME Files
But i developed but it going on first loop only i.e IME Loop only
script is given below
#!/usr/bin/sh
export DIRECTORY=/home/abc/test
export DATETIME=`date +"%y%m%d%S"`
export IME=test_ime
export GSE=test_gse
export IMF=test_imf
export GWY=test_gwy
export TMP=tmp
for file in $( find $DIRECTORY -type f -name '*.*' | sort )
do
FNAME=`echo ${file} |cut -c 16-18`
echo $FNAME
STNG=$(awk '(NR==2) { print substr($0,34,4); }' ${file})
if [ $FNAME==IME ]
then
echo $STNG"hi"
if [ $STNG=="IMCT" ]
then
echo $STNG"IMCT Loop"
mv ${WRKFILE} ${DIRECTORY}/${IME}
elif [ $STNG==GWAY ]
then
echo $STNG"GWAY Loop"
mv ${WRKFILE} ${DIRECTORY}/${GWY}
fi
elif [ $FNAME==IMF ]
then
echo $FNAME"IMF Loop"
mv ${WRKFILE} ${DIRECTORY}/${IMF}
else
mv ${DIRECTORY}/${WRKFILE} ${DIRECTORY}/${GSE}
fi
done
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2005 05:01 PM
тАО12-01-2005 05:01 PM
Re: Need Help On Script
Shalom Sir,
if [ $FNAME==IME ]
then
echo $STNG"hi"
if [ $STNG=="IMCT" ]
...
ITRC makes this very hard to read.
But it seems that IMCT is only testted for if you get a hit on IME.
I think your if/fi structure needs to be done so all items are tested for on the first loop.
Thats not how its coded now.
Also you use of quotes is inconsistent. Good shell programmers are at least consistent. Usually its better to use them than not, though it actually makes no difference if there are no whitespaces in the output.
SEP
if [ $FNAME==IME ]
then
echo $STNG"hi"
if [ $STNG=="IMCT" ]
...
ITRC makes this very hard to read.
But it seems that IMCT is only testted for if you get a hit on IME.
I think your if/fi structure needs to be done so all items are tested for on the first loop.
Thats not how its coded now.
Also you use of quotes is inconsistent. Good shell programmers are at least consistent. Usually its better to use them than not, though it actually makes no difference if there are no whitespaces in the output.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2005 06:04 PM
тАО12-01-2005 06:04 PM
Re: Need Help On Script
Thanks Steven,
Now my script is working and also i started develop script just a month back.
Now my script is working and also i started develop script just a month back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2005 06:04 PM
тАО12-01-2005 06:04 PM
Re: Need Help On Script
Thanks a lot
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP