Page 1 of 1 1
Topic Options
#77034 - 2003-10-09 05:15 PM RedirectOutput
Markus_Hahn Offline
Fresh Scripter

Registered: 2002-08-07
Posts: 8
Loc: Düsseldorf, Germany
I want to create a logfile of a FTP operation within a script. That's the relevant code:

:ftp
$log=@date+"_"+@time
RedirectOutput ("c:\logs\Download_$log.txt", 1)
? "Download " $log
?
Shell "ftp -i -s:c:\download.txt"

Open (1,"c:\logs\Download_$log.txt",2)

$L=ReadLine(1)

While @error=0
If InStr($L,"nicht verbunden.") GoTo repeat EndIf
$L=ReadLine(1)
Loop

For some reason it doesn't create the logfile. The strangest thing is that I have a login script with the same syntax which is working fine.
I use KixScript Version 4.21. Any ideas ?

Top
#77035 - 2003-10-09 05:20 PM Re: RedirectOutput
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm pretty sure you're not using the exact syntax as the @DATE and @TIME macros contains invalid characters.
code:
$log=join(split(@date,'/'),'-')+'_'+join(split(@time,':'),'-')

would be better. Please post code in between code tags.

And take a look at the UDF Forum!

Finally, ex-pat from Ratingen says 'Hi!' [Smile]

[ 09. October 2003, 17:24: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#77036 - 2003-10-10 08:17 AM Re: RedirectOutput
Markus_Hahn Offline
Fresh Scripter

Registered: 2002-08-07
Posts: 8
Loc: Düsseldorf, Germany
Great. That solved the problem that it didn't want to create the logfile. Thanks.
But it still doesen't write the output of the ftp operation into that file.
All I can find in the file is the output from this:
? "Download " $log
?

But nothing from this:
Shell "ftp -i -s:c:\download.txt"

How can I solve this issue ?

Top
#77037 - 2003-10-10 08:30 AM Re: RedirectOutput
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you use ftp.
ftp is own program.
it has it's own console.
setting kixtart's console to output file will make all kixtart output there.
but you need to do the ftp output with the means of the ftp itself.

if the ftp has no switch for log, try with simple piping the output to text file with ">"
_________________________
!

download KiXnet

Top
#77038 - 2003-10-10 03:35 PM Re: RedirectOutput
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
$logfile='c:\logs\downloads_'+join(split(@date,'/'),'-')+'_'+join(split(@time,':'),'-')+'.log'
Shell 'ftp -i -s:c:\download.txt >'+$logfile

_________________________
There are two types of vessels, submarines and targets.

Top
#77039 - 2003-10-10 04:02 PM Re: RedirectOutput
Markus_Hahn Offline
Fresh Scripter

Registered: 2002-08-07
Posts: 8
Loc: Düsseldorf, Germany
This way it unfortunately doesn't work. FTP doesn't recognize the logfile path and just outputs a list of parameters (like FTP /?).
Now I run this command (ftp > logfile.txt) in a seperate cmd which I start using the shell command and this works fine.

Top
#77040 - 2003-10-10 04:08 PM Re: RedirectOutput
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Can you do
code:
shell 'ftp <commandsin.txt >logout.log'

?
_________________________
There are two types of vessels, submarines and targets.

Top
#77041 - 2003-10-10 04:21 PM Re: RedirectOutput
Markus_Hahn Offline
Fresh Scripter

Registered: 2002-08-07
Posts: 8
Loc: Düsseldorf, Germany
No. Same error. But nevermind. You already helped me a lot. I'm now happy with what I've got. Thanks a lot.
Top
#77042 - 2003-10-11 01:59 AM Re: RedirectOutput
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
FWIW, the redirector '>' in the SHELL line most likely needs %comspec% to make it work. This is explained in an FAQ.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#77043 - 2003-10-11 01:56 PM Re: RedirectOutput
Markus_Hahn Offline
Fresh Scripter

Registered: 2002-08-07
Posts: 8
Loc: Düsseldorf, Germany
Great, you are a genius. This is how it works:

shell '%comspec% /c "ftp -i -s:c:\download.txt > c:\Download_$log.txt"'

Thanks a lot.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.082 seconds in which 0.048 seconds were spent on a total of 11 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org