BigJohn
8th May 2002, 00:13
Hi ...
I have a question ...
I am creating an extract (.xls) file using a Baan session.
As of now it gets dumped in the users HOME directory.
Now I want to ftp this file to a different server.
I have a login and password for the new server.
For e.g. My login on baan is "bigjohn".
The login on the destination server is "baanftp".
Basically I (or the users running the session) do not have permissions on the
destination server. I'll have to use the baanftp login to move the file there.
So ... I can't use client2server() function, right?
Will I have to write a shell script?
If yes, does anybody have a sample code?
My UNIX scripting knowledge is worse than my Baan Tools knowledge :o)
Cheers,
BigJohn
Hi John,
I think you are looking for this function -
Syntax
long file.mv.across.hosts( const string source, const string target )
Description
This moves a specified source file to the location specified in the target argument. The file can be either local or remote. Source and target can be on different hosts.
Return values
1 success
<0 error
Context
3GL library function.
I couldnt figure it yet to make it working. I am trying to get more clarifications from BaaN. I will post my findings when I get more information.
There is already an on-going post here for this issue -
http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1547
Bogdan
8th May 2002, 15:31
Hi BigJohn,
A very quick solution is to use an "automated" ftp transfer by passing the parameters to ftp from a file, like this one:
open server1
username1
password1
binary
get complete_path_to_server1_file local_destination_file_name
disconnect
open server2
username2
password2
binary
put local_destination_file_name complete_path_to_server2_file
disconnect
bye
Then in the BaaN session insert this code:
#pragma used dll ottdllbw
.....
app_start("ftp -s:complete_path_to_local_ftpfile","","","","")
This should work independ OS; I tested with Win workstation and AIX servers.
The ideea to all of this is to make a "bridge" between the servers trough a workstation. You can make the transfer directly (please modify the parametrs) between the servers, but maybe you want a copy of the transfered file? :)
There are also others solutions for UNIX servers like rcp; in this case you must run the command on server side.
And, the most elegant solution mentioned here by NPRao, but I can't figure out how you'll login to destination
Good luck
mark_h
8th May 2002, 16:10
Here is a sample script I keep around.
ftp -ntv<<ENDFTP >teststat
open somehost
user someuser passwd
cd somedir
put somefile
quit
ENDFTP
As far as I know for the file.mv.across.hosts you need remote login capabilty. It seems to me I read where it uses rcp, but I am not sure. At our site you are not allowed to do this, so I can not use that command. FTP and telnet are locked down on our Baan servers.
Mark
Hi John,
I think the other unix shell scripts alternatives would be -
using the rcp commands or rdist on Unix.
Here is the man/help info of rcp/rdist from our HP-UNIX.
NAME rcp - remote file copy
SYNOPSIS
Copy Single File
rcp [-p] [-S size] [-R size] source_file1 dest_file
Copy Multiple Files
rcp [-p] [-S size] [-R size] source_file1 [source_file2]... dest_dir
Copy One or More Directory Subtrees
rcp [-p] [-S size] [-R size] -r source_dir1 [source_dir2]... dest_dir
Copy Files and Directory Subtrees
rcp [-p] [-S size] [-R size] -r file_or_dir1 [file_or_dir2]... dest_dir
DESCRIPTION
The rcp command copies files, directory subtrees, or a combination of files and directory subtrees from one or more systems to another. In many respects, it is similar to the cp command (see cp(1)
NAME rdist - remote file distribution program
SYNOPSIS
rdist [ -bhinqvwyMR ] [ -f distfile ] [ -d var=value ] [ -m host ]
[ label... ]
rdist [ -bhinqvwyMR ] -c name... [ login@]host[:dest ]
DESCRIPTION
rdist facilitates the maintaining of identical copies of files over
multiple hosts. It preserves the owner, group, mode, and modification time of files if possible and can update programs that are executing.
baanconsultant
10th May 2002, 14:19
Alternative to passing password and so in the call to ftp, you can also create a file called .netrc (with dot) in the users homedirectory. This file can contain usernames, passwords and commands that will be used automatically if an ftp is done to a particular host. It might be possible to create a "general" .netrc for all users (like a .profile) but I'm not sure about this.
So, if you say
"ftp roadrunner" from Unix (or with shell(XX) from Baan) all the directions for the transfer are in the .netrc. Please look at the manpages from .netrc or ftp (man ftp, man .netrc) for more information, I don't have the exact syntax available here.
Disadvantage: if the FTP hangs (because of wrong password or so) ftp will wait endlesly, causing the calling session to hang.
popeye
29th May 2002, 03:22
Hi,
I have a Baan Function which in turn calls a shell script.
I have pasted 'em.
Hope this helps.
Cheers,
Popeye
Baan Function
function extern tccomodll00001.server2server(domain tcmcs.str20 destination.server,
domain tcmcs.str20 login,
domain tcmcs.str20 password,
domain tcmcs.str100 source.path,
domain tcmcs.str100 destination.path,
domain tcmcs.str100 source.file,
domain tcmcs.str100 destination.file,
domain tcmcs.str6 mode)
{
|* Description : This function is used for FTPing files from one server to another.
|* Parameters : 1 = Destination Server
|* 2 = Login (Destination Server)
|* 3 = Password (Destination Server)
|* 4 = Source File Path
|* 5 = Destination File Path
|* 6 = Source File Name
|* 7 = Destination File Name
|* 8 = Mode (Transfer Type : ascii, binary)
|* Return Values : None
|******************************************************************************
string hold.command(1024)
hold.command = "server2server.sh " & strip$(destination.server) & " " &
strip$(login) & " " & strip$(password) & " " & strip$(source.path) & " " &
strip$(destination.path) & " " & strip$(source.file) & " " &
strip$(destination.file) & " " & strip$(mode)
shell(strip$(hold.command),0)
}
Shell Script
# Parameters : ^M
# $1 = Destination Server^M
# $2 = Login (Destination Server)^M
# $3 = Password (Destination Server)^M
# $4 = Source File Path^M
# $5 = Destination File Path^M
# $6 = Source File Name ^M
# $7 = Destination File Name ^M
# $8 = Mode (Transfer Type : ascii, binary)^M
#************************************************************************^M
echo "Begin FTP Script..."^M
echo "open $1" > ftptmp.scr^M
echo "user $2 $3" >> ftptmp.scr^M
echo "$8" >> ftptmp.scr^M
echo "pwd" >> ftptmp.scr^M
echo "!pwd" >> ftptmp.scr^M
echo "put $4/$6 $5/$7" >> ftptmp.scr^M
#echo "cdup" >> ftptmp.scr^M
echo "close" >> ftptmp.scr^M
popeye
29th May 2002, 03:24
remove the following 2 lines from the shell script
echo "pwd" >> ftptmp.scr^M
echo "!pwd" >> ftptmp.scr^M
cheers
p!
karlovac
1st July 2002, 10:33
I saw here so many answers,
but I need one more:
How to get user input on file-name?
(I have more users which make new .xls files and transfer them to Baan server for using them as "Drawing" in EDM package)
I want to give them possibility to say which local file they want to transfer (without my intervention - and without possibility to make a mistake using FTP)
Thanks
;- )