Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Dear all,
I am not sure if its possible but I want to FTP a file across to another computer - ok so that bit works - but the same script can be run from 2 different computers so I need to find out which computer I'm on first to know to send it to the other computer. Below is what I have so far but it keeps returning the old 'unexpected end of file' and I cant find the problem.Any thoughts very much appreciated.#!/bin/bash
clear
echo "Welcome to this script"
echo " "
sleep 2# Prompt user for current show name...
echo -n "Please enter a show name (with no spaces) \"showname\" "
read showname
echo " "#### Pretend this is hard work..;-)
echo "Ok...working on it now "
echo " "
sleep 1# Copy current file to 'file_showname'
cp /this/is/to/copy /this/is/new/file_$showname
sleep 1
echo "There is now a file called 'file_$showname'."
echo " "# Overwrite the 'file_virgin file with the one we just created
cp /this/is/new/file_$showname /this/is/new/file_virgin
sleep 2
echo "'file_$showname' will be used as the file respol uses."
echo "So now when you 'respol' the system will revert "
echo "to the settings you just created."
echo " "# Identify hostname so we know where to FTP this file to
# Create a temp file to identify controller
OUT=/the/temp/file/hosttext.txt
>$OUT
echo "$(hostname)" >> $OUTif grep thiscomputername /the/temp/file/hosttext.txt
then
filename="/this/is/the/localfile"
hostname="theothercomputersname"
username="user"
password="pword"
ftp -inv $hostname <<EOF
quote USER $username
quote PASS $password
cd /put/it/here/
ascii
put $filename
quit
EOF
else
filename="/this/is/the/localfile"
hostname="thiscomputer"
username="user"
password="pword"
ftp -in $hostname <<EOF
quote USER $username
quote PASS $password
cd /put/it/here/
ascii
put $filename
quit
EOF
fisleep 2
echo " "
echo "OK..All done"
exit 0

Hi,
Make sure you're not indenting the EOF string inside your if. Once the format of this forum disallow indent, I'll use ..... instead.
Look
if bla bla
then
.....ftp -inv $hostname <<EOF
.....ftp commands...
.....quit
.....EOF (wrong)
fiAnd now:
if bla bla
then
.....ftp -inv $hostname <<EOF
.....ftp commands...
.....quit
EOF (right!!!)
fiI hope this works.
---
Fabio Berbert de Paula
http://www.vivaolinux.com.br/

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |