- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Syntax error at line 23 : `<' is not matched.
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
тАО03-03-2010 02:43 AM
тАО03-03-2010 02:43 AM
I am getting error 'Syntax error at line 23 : `<' is not matched.' in below script. Please tell me the solution for it.
This script takes comma seperated file names and ftp to different machine to get those files.
If anybody have a better script for the problem statement, sharing is much appreciated!
#!/bin/sh
set -x
#takes the input
strn=$1
#counts the number of files in string
count=`echo $strn | awk -F, {'print NF'}`
#declarations
i=1
hostname="tblusr47"
username="abansal"
password="abansal"
while [ $i -le $count ]
do
str[$i]=`echo $strn | cut -d, -f${i}`
cd /home/tagarwal/files
ftp -i -n $hostname<
quote PASS $password
binary
cd /rockblock/batch/ROCKHOLD/import
get ${str[$i]}
#echo ${str[$i]}
i=`expr $i + 1`
quit
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 02:50 AM
тАО03-03-2010 02:50 AM
Re: Syntax error at line 23 : `<' is not matched.
ftp -i -n $hostname<
I would expect there would have to be a concluding EOFTP, which I don't see.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 03:02 AM
тАО03-03-2010 03:02 AM
Re: Syntax error at line 23 : `<' is not matched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 03:13 AM
тАО03-03-2010 03:13 AM
Re: Syntax error at line 23 : `<' is not matched.
ftp -i -n $hostname<
binary
cd /rockblock/batch/ROCKHOLD/import
get ${str[$i]}
bye
EOFTP
(( i += 1 ))
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 03:26 AM
тАО03-03-2010 03:26 AM
Re: Syntax error at line 23 : `<' is not matched.
#!/bin/sh
set -x
#takes the input
strn=$1
#counts the number of files in string
count=`echo $strn | awk -F, {'print NF'}`
#declarations
i=1
hostname="tblusr47"
username="abansal"
password="abansal"
while [ $i -le $count ]
do
str[$i]=`echo $strn | cut -d, -f${i}`
cd /home/tagarwal/files
ftp -i -n $hostname<
#quote USER $username
#quote PASS $password
binary
cd /rockblock/batch/ROCKHOLD/import
get ${str[$i]}
#echo ${str[$i]}
bye
EOFTP
((i+=1))
#i=`expr $i + 1`
done
I apologize if I am not able to understand as I am not very proficient in scripting and need ur help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 04:58 AM
тАО03-03-2010 04:58 AM
Re: Syntax error at line 23 : `<' is not matched.
> set -x
Rather than permanently store the trace option in the script, you can run the script with the option set or not set, as in:
$ sh -x myscript
> #takes the input
> strn=$1
SInce the first parameter is all your files, rather than use an array to store them (str[]), just replace the comma with a space and then create the while loop with a for loop:
FILES=$(echo $1 | tr -s "," " ")
for FILENAME in $FILES
do
...
> #counts the number of files in string
> count=`echo $strn | awk -F, {'print NF'}`
count is no longer needed. Note that scripts are much easier to read if all variables are UPPERCASE and with meaningful names ($COUNTER rather than $i)
> str[$i]=`echo $strn | cut -d, -f${i}`
Not needed since $FILENAME will have each new file. Note that `` (grave accents) are deprecated as too limited and far too easy to confuse with ''. The construct $() is preferred.
> cd /home/tagarwal/files
Not needed inside the loop...just cd before the loop starts.
> ftp -i -n $hostname<
The ftp -i option is not necessary since you are only ftp'ing one file at a time.
The syntax error is with <
ftp -i -n << EOFTP
> #quote USER $username
> #quote PASS $password
The # character is not a comment inside ftp. Each of these lines will generate an ftp error message.
Here is the script simplified:
===========================================
#!/bin/sh
set -u # (prevents undetected spelling errors)
[[ $# -ne 1 ]] &&
echo "wrong parameter count" &&
exit
HOSTNAME="tblusr47"
USERNAME="abansal"
PASSWORD="abansal"
cd /home/tagarwal/files
FILES=$(echo $1 | tr -s "," " ")
for FILENAME in $FILES
do
echo "Transferring $FILENAME"
ftp -i -n $HOSTNAME << EOFTP
binary
get $FILENAME
bye
EOFTP
done
echo "Completed"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 04:59 AM
тАО03-03-2010 04:59 AM
Re: Syntax error at line 23 : `<' is not matched.
Change this:
ftp -i -n $hostname<
... to this:
ftp -i -n $hostname <
And it'll work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 05:03 AM
тАО03-03-2010 05:03 AM
Solution#!/bin/sh
set -u # (prevents undetected spelling errors)
[[ $# -ne 1 ]] &&
echo "wrong parameter count" &&
exit
HOSTNAME="tblusr47"
USERNAME="abansal"
PASSWORD="abansal"
cd /home/tagarwal/files
FILES=$(echo $1 | tr -s "," " ")
for FILENAME in $FILES
do
echo "Transferring $FILENAME"
ftp -i -n $HOSTNAME << EOFTP
user $USERNAME $PASSWORD
binary
get $FILENAME
bye
EOFTP
done
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 09:39 PM
тАО03-03-2010 09:39 PM
Re: Syntax error at line 23 : `<' is not matched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2010 02:19 PM
тАО03-04-2010 02:19 PM