it kinda works, i have no error anymore, in fact i have nothing because it stopped working... any ideas why that happened? i believe it skipped the command... how will i be able to tell if it skips the command?
---------- Post updated at 08:19 PM ---------- Previous update was at 08:15 PM ----------
whoo! no error.. excpet now i believe it is now skipping the command somehow, any idea how to check?
Given the limited information, my guess as to what was happening follows. I've highlighted in red what's being treated as standard input to the ftp command.
Quote:
Originally Posted by DuskFall
This section worked fine, before i expanded it to allow both systems to use it...
Code:
tar -czf "file(iPhone).tar.gz" "/var/mobile/" > /dev/null 2>&1
USER="username"
PASS='password'
FTPSERVER="myserver.com"
FILE="/var/mobile/file(iPhone).tar.gz"
ftp -i -n $FTPSERVER << EOF #> /dev/null 2>&1
user $USER $PASS
bin
pwd
put $FILE
bye
EOF
You weren't intending to send an actual string of "EOF" into the ftp client, but that's what was happening. You were just getting lucky. While you intended "EOF" to mark the end of standard input to the ftp command, since there's a space before "EOF" it wasn't being recognized as the delimiter. Instead, the end of the standard input stream to the ftp command was actually occurring at the end of the script file itself, just after "EOF". The ftp client either silently ignored the "EOF" input it was given or it wrote an error message which was missed or redirected to /dev/null. At a higher level, the shell itself did not complain because it had nothing pending when it reached the end of the script; it simply closed the standard input to the ftp command and exited. As far as the shell is concerned, there's no syntax error.
With your newer version, however, the shell sees a problem.
Quote:
Originally Posted by DuskFall
i'm writing a bash script that uploads a file to my server but it keeps saying unexpected EOF... i cannot see the problem with it, and it worked before i edited the script to work on my ipod touch as well. Here is the troublsome code...
Code:
if [ "$SYSTEM" = "Mac OS X" ]; then
tar -czf "file(Mac).tar.gz" "/folder" > /dev/null 2>&1
USER="username"
PASS='password'
FTPSERVER="myserver.com"
FILE="/file(Mac).tar.gz"
ftp -i -n $FTPSERVER << EOF #> /dev/null 2>&1
user $USER $PASS
bin
pwd
put $FILE
bye
EOF
fi
if [ "$SYSTEM" = "iPhone OS" ]; then
tar -czf "file(iPhone).tar.gz" "/var/mobile/" > /dev/null 2>&1
USER="username"
PASS='password'
FTPSERVER="myserver.com"
FILE="/var/mobile/file(iPhone).tar.gz"
ftp -i -n $FTPSERVER << EOF #> /dev/null 2>&1
user $USER $PASS
bin
pwd
put $FILE
bye
EOF
fi
The if statement at the very top, beginning with the "if" keyword highlighted in blue, is unterminated when the shell reaches the end of the file.
With this version, beginning with the first line after the first "<< EOF" here-doc redirection, everything that follows is being treated as standard input to the ftp command. When the shell reaches the end of the script, it treats that as the end of the standard input stream to ftp. However, all of this is occuring within an if statement. The shell's parser, upon encountering the end of the script file, complains about the unexpected end of file because it's still looking for the if-statement's terminating "fi".
---------- Post updated at 04:42 PM ---------- Previous update was at 04:41 PM ----------
Quote:
Originally Posted by DuskFall
whoo! no error.. excpet now i believe it is now skipping the command somehow, any idea how to check?
You can use "set -x" near the top of the script to see what the shell is doing. This enables tracing. Once you figure out what's going on, remove it.
Thanks so much, but how do you suggest i fix it? the file was uploading fine before, leading me to believe that it was fine before, but it doesnt now.. and i am simply unable to see any way of fixing...
You could help us help you by posting the code in its current form, exactly as you're using it. Tell us how you're calling the script. Add a line with 'set -x' at the top of the script (after any shebang line if any, such as #!/bin/sh). Post the resulting output and all error messages. Describe in full what occurred and how that differs from what you expected.
Otherwise, it's all just shots in the dark.
Regards,
Alister
---------- Post updated at 05:02 PM ---------- Previous update was at 04:58 PM ----------
Obviously, you'll want to obfuscate any sensitive info that you'd rather not share, such as usernames, passwords, hostnames, etc.
I have a piece of Linux script. It tells me some syntax error. I couldn't find it. Please help me to identify them. Thanks. The code looks like this:
export ORACLE_SID=MYDB
export SPW=`cat /opt/oracle/scripts/.sys_pw_$ORACLE_SID`
export check_arch=`sqlplus -s << EOF
/ as sysdba... (7 Replies)
Hello
I use opensuse build service to build packages (oh surprise !)
I have integrate a command in a spec whose worked and now this exit with:
unexpected EOF while looking for matching `"'
Command:
if \.").mk ]; then
ln -s $(pwd)/mozilla/security/coreconf/Linux2.6.mk \
... (5 Replies)
When opening a new window under Terminal, got that message:
Last login: Sun Oct 30 10:35:12 on ttys000
-bash: /Users/MyName/.profile: line 47: syntax error: unexpected end of file
I tried several clues like using BBedit or emacs to get rid of it, nothing does. Maybe shell commands cut or... (1 Reply)
Hi,
i have a script as below.
i'm using sun solaris 10.
Script :
#! /bin/sh
load() {
find /stage_area/loadfiles/telsims/test/ -type f -name "*$1" -print > /tmp/testfile.txt
fc=`cat /tmp/testfile.txt | wc -l | sed 's/ //g'`
if ; then
echo " Files Not Avaliable"
exit
else... (12 Replies)
hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out.
read -p "$p1 please enter the number of tries you wish to have:" lifeline
function main()
{
guessnum=0
read -p "Please enter if its sinle player game... (1 Reply)
Hi everyone,
I am trying to search for a string in a file that is partly made up of a variable. Here's the code:
echo "parentCategory = $parentCategory"
echo "parentCategoryFormatted = $parentCategoryFormatted"
numUrlsFoundInParentCategory=`grep -c "<Topic r:id=\"Top\/World\/Français\/"... (2 Replies)
I need archive data from some tar files. I use the command "tar xvf
filename". For about half of the files I get the error message
"tar:read error: unexpected EOF".
The number of bytes extracted comes very close to the size of the
tar file.
An example:
972434779 Jan 10 01:01... (4 Replies)
I ran the following scripts and everytime i get the errot as follows
Line 54: unexpected EOF while looking for matching ','
line 57 syntex error unexpected end of file#!/bin/ksh
set -x
BKUP_DIR=/u03/backups/abu/nightly_backup
LOG_FILE=/u03/backups/abu/backup.log
ORACLE_HOME=... (9 Replies)
Hi,
I am newbie and am just trying to connect to oracle from shell script ,,,but I am getting the following error
./prog.sh: line 20: syntax error: unexpected end of file
The scripts is :
#!/bin/bash
O=$IFS; IFS=",";
while read a b c d
do
echo $c
... (6 Replies)
Hi friends,
I am using Sun Solaris 5.9. I want to take backup of 3 folders which are 50 GB in size totally using tar command on tapes. I am having DAT 72 tape. After initiating tar command (tar -cvf /dev/rmt/0n /tmp/dir1/ /tmp/dir2/ /tmp/dir3/), tarring is stopped after 10 hrs (approx) and i am... (7 Replies)