dhruv_x0
27th August 2015, 13:39
Hi Guys,

I have a directory in my local machine and there are 20 files(dynamic names each time) which need to be read. I am using dir.open(),dir.entry() functions to do that. Before i can use these functions this directory should exists on server. Can we do that using client2server? I tried but i am getting error(-3).
Is there anything else we can use to do that?

Appreciate any suggestions on this.

Thanks

bhushanchanda
27th August 2015, 15:00
Hi,

Error -3 indicates, the destination directory doesn't exists.

What I will suggest is, you can use run.prog() to create the required directory.
In case if you have Unix/Linux OS, you can also use shell() command.

e.g. For windows based server -

ret = run.prog("cmd.exe","cmd /c mkdir" & dir.name,RP_WAIT)

e.g. dir.name = "C:\Bhushan\test123"

So, run this code before doing client2server()

dhruv_x0
27th August 2015, 15:50
Hi,

I use run.prog and it create a directory on the server but when i doing client2server its still giving(-3). Don't understand what i am missing.
Below is the code for that

domain tcmcs.str100 dir.name
dir.name = "E:\junk\expense"
file.path = "C:\XMDBTOOL\XMDBTool - HARSCO\DownloadedData\"
ret = run.prog("cmd.exe","cmd /c mkdir " & dir.name,RP_WAIT)
ser.path = dir.name
ret = client2server(file.path, ser.path, false, false)
fd = dir.open(ser.path)
if fd < 0 then
message("Directory Can not be Openend")
return
endif

Thanks

Anmol

bhushanchanda
27th August 2015, 15:57
Hi,

In addition to my previous post - There's an inbuilt function mkdir() as well. You can use that.

Check if the directory is created or not.

Also, you can't simply use client2server to move folders. You need to transfer files one by one to the destination folder.

Syntax:
function long mkdir (string path_name$)

Description

This creates a specified directory (local or remote). You must have write permission in the parent directory to do this. Access permissions for the new directory are set to read, write, and execute for all users. The path_name$ argument must include the full path to the directory, including the host name, where appropriate. For example:

mkdir( "host1!/usr/mydir" )


Arguments
string path_name$

Return values
>=0 Success. (If the return value is 0 then you can be sure that the directory existed already.)
<0 Error. The error code is stored in the e variable.

JaapJD
27th August 2015, 16:01
To create directory on server, use mkdir(). Note that dir.open() and dir.entry() work on directories on the server. I don't think there are functions to read the contents of a directory on the client.

dhruv_x0
27th August 2015, 16:12
Yes if i know the file names then it could have done easily..in this case i don't know the file names(only 15 chars in each file are known). I am just thinking how can i move those files.

bhushanchanda
27th August 2015, 16:20
Hi,

You can install psexec utility which can be installed on Client machine. Or use inbuilt xcopy or robocopy or a simple copy command on client machine to copy the folder to server.

To run the commands, you can use start.application.local()

Google it and you can create a command on your own.

Note- Unfortunately, these functions won't be available in later versions.

JaapJD
27th August 2015, 16:21
Maybe you can zip them into one file on the client and use client2server() to copy the zip file to the server? The LN FP9 Tools (10.3) have functions to unzip on the server. Then you can use dir.open() and dir.entry() to process the individual files.

dhruv_x0
27th August 2015, 16:40
I don't want to install third party things....surely there should be something. I saw this on baanboard.
http://www.baanboard.com/baanboard/showthread.php?t=62410 and here is the code from Gunther. I am trying to findout the work of app_start in this.
rc = app_start("cmd.exe /C " &
"dir /B " & strip$(dir.client) & "\" & file &
" >" & strip$(dir.f),
"", "", "", "")

if rc > 0 then
wait(rc, WTHANG)
endif

MY.DELAY(1.0) | might by essantial to wait at 1 second!

long i
for i = 1 to 10
rc = client2server(dir.f, dir.t, TRUE, TRUE)
if rc = 0 then
break
endif
MY.DELAY(1.0)
endfor

MY.DELAY(1.0)
remove.local.file(dir.f)


Thanks

Anmol

bhushanchanda
27th August 2015, 16:50
Hi,

app_start is depreciated. start.application.local() is the replacement.

Its runs a program on client machine. As mentioned earlier, copy/robocopy/xcopy these are not 3rd party but inbuilt windows commands.

The solution mentioned by Gunther will work just fine -

It runs dir function on the local folder within the command prompt, and stores the output to file dir.f. The dir.f should contain all the file names in the local folder.

Now, you can read this file and use client2server for each line.

Well, there can be many possible solutions. The one mentioned by Jaap is good as well. You need to choose the best-fit for yourself.

One more similar thread (http://www.baanboard.com/baanboard/showthread.php?t=9091)