- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Scripting Help .. Please Help
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
Forums
Discussions
Discussions
Discussions
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
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
08-27-2003 07:10 PM
08-27-2003 07:10 PM
I am trying write a shell script to accomplish following:
This is what I want:
I have a file1 with following content:
xxx1 100 105
xxx2 200 210
xxx3 150 175
For each line of this file, I need to genearte a new file with contenats and file name
in the pattern:
file: xxx1.bif
http://yyy.com/test.cgi?cmd=item-100&group=xxx1
http://yyy.com/test.cgi?cmd=item-101&group=xxx1
..
..
http://yyy.com/test.cgi?cmd=item-105&group=xxx1
file: xxx2.bif
http://yyy.com/test.cgi?cmd=item-200&group=xxx2
http://yyy.com/test.cgi?cmd=item-201&group=xxx2
..
..
http://yyy.com/test.cgi?cmd=item-210&group=xxx2
I am trying following script and it doesn't work:
infile=test.txt
url="http://yyy.com/test.cgi?cmd=item-"
uri="group="
suffix=".bif"
cat $infile | while read name start end
do
filename=`expr $name$suffix`
if [$end -gt $start]
then
while [$end -ge $start]
do
echo $url$end$uri$name >> $filename
echo "<
end=`expr $end-1`
done
fi
done
Any help is appreciated. The inner loop fails.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 07:35 PM
08-27-2003 07:35 PM
Re: Shell Scripting Help .. Please Help
Not knowing the error code, I'll suggest this:
change this:
echo $url$end$uri$name >> $filename
to
echo "${url} ${end} ${uri} ${name}" >> $filename
The spaces may not be necessary. If I can't sleep I'll actually try and run your script and debug it later.
SEP
Will work for points.
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
08-27-2003 09:02 PM
08-27-2003 09:02 PM
Re: Shell Scripting Help .. Please Help
I get following message when I execute the script:
./test.csh: [105: not found
./test.csh: [210: not found
./test.csh: [175: not found
I believe it may be due to some syntax error. But I am not able to figure out what it is...
Thanks
Praveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 09:43 PM
08-27-2003 09:43 PM
SolutionAssuming you don't mind the "<
infile=test.txt
url="http://yyy.com/test.cgi?cmd=item-"
uri="&group="
suffix=".bif"
cat $infile | while read name start end
do
filename=`expr $name$suffix`
if [ $end -gt $start ]
then
while [ $end -ge $start ]
do
echo $url$end$uri$name >> $filename
echo "<
end=`expr $end - 1`
done
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 09:46 PM
08-27-2003 09:46 PM
Re: Shell Scripting Help .. Please Help
Assuming you don't mind the "<
infile=test.txt
url="http://yyy.com/test.cgi?cmd=item-"
uri="&group="
suffix=".bif"
cat $infile | while read name start end
do
filename=`expr $name$suffix`
if [ $end -gt $start ]
then
while [ $end -ge $start ]
do
echo $url$end$uri$name >> $filename
echo "<
end=`expr $end - 1`
done
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 09:46 PM
08-27-2003 09:46 PM
Re: Shell Scripting Help .. Please Help
Assuming you don't mind the "<
infile=test.txt
url="http://yyy.com/test.cgi?cmd=item-"
uri="&group="
suffix=".bif"
cat $infile | while read name start end
do
filename=`expr $name$suffix`
if [ $end -gt $start ]
then
while [ $end -ge $start ]
do
echo $url$end$uri$name >> $filename
echo "<
end=`expr $end - 1`
done
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 10:10 PM
08-27-2003 10:10 PM
Re: Shell Scripting Help .. Please Help
try to give a space before the value being tested in every "test" command.
Ex:instead of if [$end -gt $start] or while [$end -ge $start], please use if [ $end -gt $start ], while [ $end -ge $start ].
Regards.
ALPER ONEY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 10:37 PM
08-27-2003 10:37 PM
Re: Shell Scripting Help .. Please Help
try this:
cat $infile | while read name start end
do
START=0
FINAL=0
filename=$name$suffix
if [$end -gt $start]
then
START=$start
FINAL=$end
while (($FINAL >= $START))
do
echo $url$START$uri$name >> $filename
echo "<
let START=START+1
done
fi
done
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2003 11:15 PM
08-27-2003 11:15 PM
Re: Shell Scripting Help .. Please Help
if you combine the advice given by Alper and Massimo, I think you should be there.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 06:51 AM
08-28-2003 06:51 AM
Re: Shell Scripting Help .. Please Help
#!/usr/bin/sh
for $file in file* ; do
perl -ane 'print "http://yyy.com/test.cgi?cmd=item-$_\&group=$F[0]\n" foreach ($F[1]..$F[2])' $file >${file}.bif
done
perl is handy for breaking up text and generating other data.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 07:46 AM
08-28-2003 07:46 AM
Re: Shell Scripting Help .. Please Help
Your all suggestions worked.
Rodney, I haven't tried Perl. I will try.
Thanks all for quick answers.
I like this forum.
Praveen