BaanInOhio
10th November 2008, 06:21
I need some recommendations from the HP/Unix pros in the house.
I have a requirement to FTP files from a HP/UX server to a windows-based FTP site. Since the FTP server is in the DMZ, I can't access it like other boxes in the network (RCP in a shell script, 'file.mv.across.hosts', 'server2client', etc.).
My first try was to create a shell script that accepts the from and to locations/filenames then execute the FTP (connect using server/password, set ascii, set locations on unix server and ftp site, put filename, bye) and execute it thru 'run.prog'. The files are ascii, around 500 byte records. The number of lines varies from a few to thousands.
Running the script from a unix prompt after shelling from Baan copies the file as expected. -- BUT -- Executing the Baan session that calls the same shell script using 'run.prog' with mode = "RP_WAIT" consistently cuts off the last 1000 or so bytes of the file. The break isn't consistent, and normally not at the end of a line. I tried to replace the run.prog with shell using options to run the script in a separate window with requiring <enter> to complete -same result. Even used FTP thru 'curl' and received the same truncated file. The FTP does not return an error, only results in a file on the ftp site that's smaller than the one sent.
Any recommendations on where to start looking?
spartacus
10th November 2008, 11:53
We use a job to send data from Baan to a remote recipient. Data is generated by a "normal" Baan-Session. The ftp-script ist executed from the same job with: ttaad5205m000.
Perhaps can you also make a short test with ttaad5205m000 and a job?
Regards
_Ralph_
10th November 2008, 16:59
In this thread
http://www.baanboard.com/baanboard/showthread.php?t=53937&
I posted a sample script using tools ftp functions documented on only one version of programmers guide. You can try it.
dorleta
10th November 2008, 17:34
I did it using a net.rec file. It may be works for you also.
good luck
function extern long aepurdll0002.export.sap(domain tcmcs.str80 fich, long proceso)
{
table taepur001
string scomando(200)
string linea.ftp(200)
long file.ftp, file.null
select aepur001.*
from aepur001
where aepur001._index1={:proceso}
selectdo
endselect
|Genera el fichero txt del ftp batch
file.ftp = seq.open(".netrc", "w")
if file.ftp < 1 then
message("No se puede exportar el fichero")
return (0) | Error openning file
endif
linea.ftp = sprintf$("%s %s ","machine",strip$(aepur001.dire)) |OPEN
linea.ftp = linea.ftp & sprintf$("login %s ",strip$(aepur001.user)) |USUARIO
linea.ftp = linea.ftp & sprintf$("password %s",strip$(aepur001.pass)) |PASSWORD
seq.puts(linea.ftp, file.ftp)
linea.ftp = sprintf$("macdef init") |INIT
seq.puts(linea.ftp, file.ftp)
linea.ftp = sprintf$("%s","ascii") |ASCII
seq.puts(linea.ftp, file.ftp)
linea.ftp = sprintf$("%s %s","cd",strip$(aepur001.path)) |CD **
seq.puts(linea.ftp, file.ftp)
linea.ftp = sprintf$("%s %s","delete",strip$(fich)) |erase remote file
seq.puts(linea.ftp, file.ftp)
linea.ftp = "append " & strip$(aepur001.dir2) & strip$(fich) & " " & strip$(aepur001.path) & strip$(fich)|APPEND **
seq.puts(linea.ftp, file.ftp)
linea.ftp = sprintf$("%s","quit") |QUIT
seq.puts(linea.ftp, file.ftp)
seq.puts("", file.ftp)
seq.close(file.ftp)
|Cambia el modo del fichero .netrc
scomando = "chmod 600 .netrc"
if shell(scomando , 0) <> 0 then
message("it is not possible to send file")
return(0)
endif
|Ejecuta el ftp batch
scomando = "ftp " & strip$(aepur001.dire)
if shell(scomando , 0) <> 0 then
message("")
return(0)
endif
|Borra el fichero ftp batch
scomando = "rm .netrc"
if shell(scomando , 0) <> 0 then
message("it´s not posible to delete sender file")
return(0)
endif
return(1)
}
NPRao
11th November 2008, 01:00
I have a requirement to FTP files from a HP/UX server to a windows-based FTP site. Since the FTP server is in the DMZ, I can't access it like other boxes in the network (RCP in a shell script, 'file.mv.across.hosts', 'server2client', etc.).
Since you are already on HP-UX, have you considered to use the sftp:
$ man sftp
SFTP(1) SFTP(1)
NAME
sftp - secure file transfer program
SYNOPSIS
sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config] [-o
ssh_option] [-P sftp_server_path] [-R num_requests] [-S program] [-s
subsystem | sftp_server] host
sftp [[user@] host[:file[file]]]
sftp [[user@] host[:dir[/]]]
sftp -b batchfile [user@]host
DESCRIPTION
sftp is an interactive file transfer program, similar to ftp(1), which performs all operations over an encrypted ssh(1) transport. It may also use many features of ssh, such as public key authentication and compression. sftp connects and logs into the specified host, then enters an interactive command mode.
The second usage format will retrieve files automatically if a non- interactive authentication method is used; otherwise it will do so after successful interactive authentication.
The third usage format allows sftp to start in a remote directory. Ralph, those ftp functions are valid for LN/6.1 Tools. I am not sure if they work in Baan-4/5 versions.
BaanInOhio
11th November 2008, 04:40
those ftp functions are valid for LN/6.1 Tools. I am not sure if they work in Baan-4/5 versions.
I tried those a while ago and couldn't compile - figured that they weren't available in IV - couldn't locate them in any of the includes.
I will try the batch job - but wanted it to be interactive if possible.
Interesting thing is that the FTP script works perfect when running from ksh, but cuts the end off of the file when running the exact same script and files from Baan's 'shell' or 'run.prog'. Even more interesting that running FTP thru 'curl' provided the same incomplete file.
frigyesg
11th November 2008, 11:13
We are using the same functionalaty from Linux to Windows2003 without problmes with run.prog.
But You could also try the shell command. I don´t know if it makes a difference, but you could test it.
Hitesh Shah
11th November 2008, 13:44
As suggested by NP sftp should work for this server in DMZ .