sorry for the title, most of you must getting sick of reading something like
this, but I haven't found a solution, although I found many threads according
to it.
I'm working on a bash script that connects to a network printer with ftp
where I want to upload a pdf created with fpdf, which should be printed. This bash script should later be called via cronjob.
But I've already got a problem with the first step.
I've tested the script which I found with the help of google, but my test pdf file
seems not to be fully uploaded until the script ends.
I have read, that when using a "here document", the commands should be
executed as if they were typed, but the put-command seems to be aborted as
the last few bytes seems to be missing.
I tried the sleep-command after the put,but then I receive an "?Invalid
Command" error.
the primary script:
When I do those steps in the terminal, the network printer prints my
test.pdf.
I would be very thankful if someone could help me, or can show me a
related thread. Everyting I found already, couldn't help me.
I copy/pasted your code snippet into a new bash script, changed the username, password, testfile, and FTP server, then it ran just fine.
Try changing the first line to:
You can get a better idea of where it's failing.
You can't put a "sleep" between the "<<EOD" and "EOD" since FTP doesn't understand that command.
If you're missing bytes, you probably need to issue a "bin" (binary) command prior to your "put", otherwise the end-of-line character can get affected. FTP transfers over ASCII mode by default.
Also, the FTP "put" command with a single argument implies the location of the local file is the same as the remote file, so if you do this:
You are telling FTP to upload the local file /path/to/file.txt to the FTP's remote directory /path/to/, which may not exist. Perhaps you mean to do this:
FTP defaults to "binary". Try the ftp "status" command just after logging in.
Many versions of ftp will try to deduce the transfer type based on the MSDOS style filename (e.g. .txt) unless told otherwise. Always good to postively state ascii or binary.
Let's check that the script is in the correct unix text file format. This sed is designed to make spaces and control characters visible.
Many laser printers need a formfeed character at the end of the document. Otherwise they wait until the connection times out before emptying the print buffer.
It works now, at least when I try it from my laptop.
I'll try it over night now on the server with the cronjob.
Although the terminal "told" me, that it was using binary mode when applying
my primary script, the idea with the bin-command before using the
put command seemed to make the difference.
I am trying to upload a file to the server using bash script in html form.
<FORM NAME="FORM1" METHOD="post" enctype="multipart/form-data" ACTION="/cgi-bin/UPLOAD.sh">
<INPUT type="file" name="DOCFILE" id="DOCFILE"
accept=".jpg,.tif,.pdf">
</FORM>
How can I able to access the file in... (8 Replies)
Hi,
I have one FTP script which simply sends the file to target server via netrc.it used to work as normal for years.recently target server IP got changed , same has been updated in .netrc but unable to connect it via FTP though netwrk guys already opened the port 21,20 and 22 .
NETRC... (7 Replies)
Hi,
Im a newbie with programming and shell scripting. Im running OSX/Mac and Darwin.
I would like to create a shell script that would :
1. Search a Volume and directory (including subdirectories) for a file that :
* filename ends with ”_Highres.pdf” and
* the file creation date of... (8 Replies)
Hello,
I have a script that finds the latest version of a file in a folder on my Minecraft server. I'm trying to come up with something that will then FTP that file over to my fileserver.
Here's what I have that finds the newest file:
find /home/mc/archive/sbhouse -type f -mtime +45 -exec... (7 Replies)
Can any one help in writing FTP upload script using bash ..
with specific port
-oPort=62022
#/bin/bash
FTPU="username" # ftp login name
FTPP="password" # ftp password
FTPS="localhost.com" # remote ftp server
FTPF="/test" # remote ftp server directory for $FTPU & $FTPP
port="2345"... (3 Replies)
Hi All,
I am new to this forum and i need help from you .
Here i want to get a mail conformation when ever the file was uploaded to FTP server.Here is my FTP script . Can any one plz help me how to get a mail confirmation weather the file was uploaded or not.
#!bin/sh
HOST='192.168.2.85'... (4 Replies)
Hi everyone!
I'm in a need of a shell script that search for all files in a folder, move all those files to a temp folder, and upload those files via FTP. When the file transfer via FTP completes successfully, the file is moved to a completed folder. In case any of those files fails, the file... (4 Replies)
Hi
I'm having some trouble with a bash shell script that I'm writing. In the script, I'm trying to upload a file to a backup repository using ftp, but the whole file doesn't get uploaded.
This is the file's properties at the start (I've highlighted the file size in red):
-rw-r--r-- 1 root... (2 Replies)
I have a ftp server up , however when I upload a file from my desktop to the server I get this message:
ftp> get uploadtest.txt
Local: uploadtest.txt Remote: uploadtest.txt
227 passive Mode ( 192,168,0,1,190,75)
550 Failed to open file
ftp> (3 Replies)
Hi!
I'd like to upload a complete folder with subfolders with put. At the moment I always get the err-msg:
aboutme: not a plain file
Could anyone help me??
Thanx (3 Replies)