There are many ways to do this, but let's move on.
I didn't read this closely enough, but I see how this is a rudimentary system for users to retain files if they name the file "File I Want" plus whatever else is needed to identify it by user and possibly content. There would never be a file created on the server in this case because the local file cannot be opened for reading. If there is no file called "$fileName" then FTP will complain about trying to open a non-existant file.
I agree with PigDog's analysis of the parameters not necessarily being files, but in the case where $2 passes the "File I Want" test and there is a value for $1 (definitely a file expected - but is it really there?) the script will move $1 to the archive directory, move $2 to the dated filename, and ftp that name. Check for FTP majick in these, but a quick test is to start with this:
If run from a script, unless these are specifically sourced at the top they will be ignored. I'll bet there is something in either /etc/profile, /etc/login, ~/.bashrc, or ~/.login that is allowing this to run interactively. Not everything is identical to interactive when run from a script - especially when run from a cron job. If the 0-byte file getting created has the correct name, the is not an issue. If it was a port blocking issue, wouldn't manually uploading the file fail as well? Mebbe. There is a part where I say something along the lines of manually uploading the file works fine. You may want to re-read my OP (and maybe some of the replies here, too). Whether you are using port 20, 2020, 2120, or whatever, that port must be allowed through your firewall and/or iptables. What port is being used for data? The standard port for ftp is 21, with data running on port 20. I see port 2121 is being used for FTP commands. The file names contain spaces and the symbol.
The files are PDFs and are anywhere fro 30-60 MB in size.When I upload the file by hand, via the CLI using the same ftp client the script uses, it uploads without issue. All other script functions work without issue. When I run the script manually, the same behavior. When the script runs via incron, it moves the file and appends the date as expected (the file is intact and not corrupt), and emails out that the file has been uploaded, but when it FTPs the file it's only 0 bytes. Mv $arcLoc/ " $2 " $arcLoc/ " $fileName "įtp -n 2121 ' $notifyRecipient << EOF The following file has been uploaded to the FTP server: $fileName Please contact us if there are any issues. BASH #!/bin/bash if ] then arcLoc = "/home/archive/file_archive" fileName = $(date +%Y%m%d )- $2 ftpUser = "ftp-user" ftpPW = "ftp-password" notifyRecipient = " $1 " $arcLoc