- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ftp script question ..
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-31-2001 09:05 AM
08-31-2001 09:05 AM
#!/usr/bin/sh
HOSTNAME_FILE=ivrs.txt
for host in $(cat $HOSTNAME_FILE)
do
ftp -n << EOF
open $host
user username password
lcd /home/richardl/english
cd netip
put *.vox
done
#
#.end
When I run it I get
./testftp[3]: Syntax error at line 5 : `<<' is not matched.
why am i getting that error?
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 09:11 AM
08-31-2001 09:11 AM
SolutionThe ftp -n << EOF is the 'here docs' convention.
It means take input from the script until it sees the string 'EOF' at the beginning of a line. You appear to be missing the 'EOF' which should follow your last ftp command (quit).
By the way, you can use any string 'XXX', '!!!', '!EOF!', ... just so long as the << XXX is matched with XXX.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 09:12 AM
08-31-2001 09:12 AM
Re: ftp script question ..
Before the done put
quit
EOF
you need to "quit" from ftp and tell the shell that your redirected input (<
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 09:12 AM
08-31-2001 09:12 AM
Re: ftp script question ..
you need a "EOF" after the put *.vox and b4 the done line.
-Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 09:16 AM
08-31-2001 09:16 AM
Re: ftp script question ..
should be
put *.vox
quit
EOF
done
Also if you are using multiple files you have to use prompt and mput rather than put so your script would look like
/Begin/
#!/usr/bin/sh
HOSTNAME_FILE=ivrs.txt
for host in $(cat $HOSTNAME_FILE)
do
ftp -n << EOF
open $host
user username password
prompt
lcd /home/richardl/english
cd netip
mput *.vox
quit
EOF
done
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 09:17 AM
08-31-2001 09:17 AM
Re: ftp script question ..
You forgot EOF just before
done.
Also you need to say quit before EOF
..........
put *.vox
quit
EOF
done
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:05 AM
08-31-2001 11:05 AM
Re: ftp script question ..
#!/usr/bin/sh
PATH=/usr/sbin/ping:/usr/bin/:${PATH}
export PATH
cd /home/richardl
HOSTNAME_FILE=ivrs
for host in $(cat $HOSTNAME_FILE)
do
/usr/sbin/ping $host -n 1 | grep -q '1 packets received'
if [ $? = 0 ]
then
echo "$host down"
else
ftp -n << EOF
open $host
so it pings the host if i fails to go into a file. And if ping does not fail to proceed with the ftp. But for some reason it is bypassing the ftp statement and even if the ping is good that it tells me the host is down.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:14 AM
08-31-2001 11:14 AM
Re: ftp script question ..
Try this:
if [ $? = 0 ]
then
ftp -n << EOF
...
...
...
EOF
else
echo "$host down"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:18 AM
08-31-2001 11:18 AM
Re: ftp script question ..
Your logic seems ok, its just that in your if statement change it to !=
because when it pings the machine the output is 0 and when it fails it 1
so change it to
#!/usr/bin/sh
PATH=/usr/sbin/ping:/usr/bin/:${PATH}
export PATH
cd /home/richardl
HOSTNAME_FILE=ivrs
for host in $(cat $HOSTNAME_FILE)
do
/usr/sbin/ping $host -n 1 | grep -q '1 packets received'
if [ $? != 0 ]
then
echo "$host down"
else
ftp -n << EOF
open $host
-Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:18 AM
08-31-2001 11:18 AM
Re: ftp script question ..
Change:
# if [ $? = 0 ]
...to...
# if [ $? -eq 0 ]
...and your test will work.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 11:37 AM
08-31-2001 11:37 AM
Re: ftp script question ..
Ooops! No points for me! Patrick & Ramesh are correct. You have the test backwards.
Either [ $? -ne 0 ] or [ $? != 0 ] in lieu of [ $? = 0 ] will fix your problem.
...JRF...