- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shell function + "<<" got error.
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
11-02-2006 07:14 PM
11-02-2006 07:14 PM
shell function + "<<" got error.
my shell script contain a ftp function
ftp ()
{
ftp HOSTNAME << EOF > /dev/null 2>&1
username....
...
..
EOF
}
don't know why it got a syntax error ...
"Syntax error at line 15 : `<<' is not matched."
any idea?
thanks
WAR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 07:47 PM
11-02-2006 07:47 PM
Re: shell function + "<<" got error.
change your function name from ftp (reserved name). Also shouldn't HOSTNAME be $HOSTNAME
For earlier solutions please see:
#! /usr/bin/sh
ip_address=a.b.c.d
user=user
password=password
ftp -n $ip_address << EOF
user $user $password
cd /tmp
lcd /tmp
bin
mput *
bye
EOF
or
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=991609
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 07:47 PM
11-02-2006 07:47 PM
Re: shell function + "<<" got error.
here is from example :
#!/bin/sh
ftp -n host > ftp.log <<-EOF
user ftp ftp_password
asc
get test123
quit
EOF
regards,
ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 07:56 PM
11-02-2006 07:56 PM
Re: shell function + "<<" got error.
the ftp script work if it is not call in the function.
my problem is when the "<<" use in the function , it got an syntax error...
any idea?
Thanks!
WAR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 08:18 PM
11-02-2006 08:18 PM
Re: shell function + "<<" got error.
please test:
#!/usr/bin/sh
ftpr ()
{
echo " Starting ftpr"
/usr/bin/ftp -n $1 << EOF > ftpdata.log 2>&1
user ftpuserid ftpuserpwd
ls
quit
EOF
echo "Leaving ftpr"
}
echo "Before the call"
ftpr 10.10.10.10
echo "After the call"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 09:55 PM
11-02-2006 09:55 PM
Re: shell function + "<<" got error.
While somewhat misleading, this error simply indicates that your EOF marker is *not* absolutely flush-left without prepended spaces.
Your 'EOF' must begin in column-1 without any leading spaces or tabs!
If you use the syntax:
... <<- EOF
...
EOF
...where only *tabs* are used to indent, you may beautify your code. Note the "-" appended to the redirection.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 10:05 PM
11-02-2006 10:05 PM
Re: shell function + "<<" got error.
I think your contruct results in a recursive call of your function:
The 'ftp' in your 'ftp' function will NOT call /usr/bin/ftp but the funtion itself again.
CHange the name of your function or you /usr/bin/ftp in the function body.
mfG Peter
PS: Nevertheless your 'EOF' marker has to be left adjusted.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 08:35 PM
12-18-2006 08:35 PM