Page 2 of 2 <12
Topic Options
#179339 - 2007-08-15 02:21 PM Re: Problem with ftpget( ) UDF. [Re: Mart]
Maurits Offline
Fresh Scripter

Registered: 2007-04-23
Posts: 16
Loc: The Netherlands
I know I can use windows ftp. I'm using it right now in my update script.
All works great. Accept that when users log in and my loginscipt calls
the update script everyone can see the commands I send to the ftp server.
I don't want that to happen but windows ftp can't hide all the commands.

This is a part of my script I'm now using with windows ftp:
 Code:
 
md $locatie + "\temp\" + @WKSTA
cd $locatie + "\temp\" + @WKSTA
shell "ftp -v -i -s:$locatie\utils\ftp.opd $rs6000"

Because of all the commands you see when you log in I wanted te use FTPget()

Top
#179340 - 2007-08-15 02:28 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
well, the easiest way to make users not even aware of what you are running is to make it run under system instead (under computer - scripts in a gpo..). That is in my opinion the easiest and best approach if you don't run administrative scripts from your own box as well. Running it as the user, and not using tokenized (or somehow obfuscated code) is a hazard in it self, since the user can then without problems read and access everything..

Edited by Björn (2007-08-15 02:30 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#179343 - 2007-08-15 03:03 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
SetConsole("Hide") maybe?
FTPInput.txt
 Code:
open ftp.microsoft.com
user anonymous pass anonymous
cd ResKit/win2000
mget jt.*
quit

FTPTest.kix
 Code:
Break ON
$SO = SetConsole("Hide")
Shell 'ftp -i -n -v -s:C:\test\FTPInput.txt'
$so = SetConsole("Show")

Top
#179351 - 2007-08-15 06:51 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Maurits27
Because of all the commands you see when you log in I wanted te use FTPget()


Did you try the FTPDir() that I posted on the previous page?

Top
#179357 - 2007-08-15 08:27 PM Re: Problem with ftpget( ) UDF. [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what previous page?
why I only have this page \:\(
_________________________
!

download KiXnet

Top
#179391 - 2007-08-16 10:44 AM Re: Problem with ftpget( ) UDF. [Re: Witto]
Maurits Offline
Fresh Scripter

Registered: 2007-04-23
Posts: 16
Loc: The Netherlands
 Originally Posted By: Witto
SetConsole("Hide") maybe?
FTPTest.kix
 Code:
Break ON
$SO = SetConsole("Hide")
Shell 'ftp -i -n -v -s:C:\test\FTPInput.txt'
$so = SetConsole("Show")


I have tested above but it doesn't work. Thanks for your input.

Top
#179394 - 2007-08-16 12:07 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Have you tried the input file and the script file I wrote?
If you launch it at a command prompt, the command prompt dissapears.
But I make reappear with
$so = SetConsole("Show")
because otherwise, the command stays running in background
Don't forget to change the path to the place where you stored the example input file:
-s:C:\test\FTPInput.txt

If you would launch the script at a command prompt like this:
start kix32 ftptest.kix
you would see twice a window popping up:
  • At the beginning of the script, before
    $SO = SetConsole("Hide")
  • At the end of the script, after
    $SO = SetConsole("Show")

Than, the window should disappear.
In that case, you can drop the last SetConsole.

Top
#179395 - 2007-08-16 01:27 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'll repost once as I'm getting confused as to whom you are responding...


Did you try the following:

 Originally Posted By: MySelf!
To get a directory list you just need to get the HTML page and parse it.

Here is a rough example adapted from FTPGet() - you may need to change the parsing rules depending on the response from the Web server.

Note, there is no sanity checking on the path or the returned data type. GIGO.

 Code:
Break ON
$=SetOption("Explicit","ON")
 
Dim $sFile,$sFileList,$sURL
 
$sURL="ftp://ftp.microsoft.com/deskapps"
 
$sFileList=FTPDir($sURL)
If $sFileList
	"Entries in "+$sURL+":"+@CRLF
	For Each $sFile in Split($sFileList,@CRLF)
		$sFile+" is a "+IIf(Right($sFile,1)="/","DIRECTORY","FILE")+@CRLF
	Next
Else
	"There are no entries in "+$sURL+@CRLF
EndIf
 
Function FTPDir($sURL,Optional $sUser, $sPass, $iForce)
	Dim $oFTP,$,$iERROR,$sLine,$iParse,$sLoc,$dwSM
 
	$iERROR=0
	$iParse=0
	$sLoc="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
	$sUser=""+$sUser
	If $iForce
		$dwSM = Readvalue($sLoc,"Syncmode5")
		$=writevalue($sLoc,"Syncmode5",3,"REG_DWORD")
	EndIf
	$oFTP = CreateObject("Microsoft.XMLHTTP")
	If @error $ftpget=1 Else
		If $sUser $oFTP.Open("GET", $sURL, Not 1, $sUser, $sPass) Else $oFTP.Open("GET", $sURL, Not 1) EndIf
		If @error $ftpget=3 Else
			$oFTP.Send
			For Each $sLine in Split($oFTP.responseBody,@CRLF)
				Select
				Case InStr($sLine,"<PRE>") $iParse=1
				Case InStr($sLine,"</PRE>") $iParse=0
				Case $iParse
					$sLine=Split($sLine+'<A HREF="','<A HREF="')[1]
					$sLine=Split($sLine,'"')[0]
					If $sLine $FTPDir=$FTPDir+@CRLF+$sLine EndIf
				EndSelect
			Next
		EndIf
	EndIf
	$oFTP=0
	If $iForce $=WriteValue($sLoc,"Syncmode5",$dwSM,"REG_DWORD") EndIf
	$FTPDir=SubStr($FTPDir,3)
	Exit $iERROR
EndFunction
;
; vim: ts=4 sw=4 ai filetype=kix

Top
#179396 - 2007-08-16 05:07 PM Re: Problem with ftpget( ) UDF. [Re: Maurits]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Or this (please copy, paste, modify
-s:C:\test\FTPInput.txt
and give it a try)
FTPInput.txt
 Code:
open ftp.microsoft.com
user anonymous pass anonymous
cd ResKit/win2000
mget jt.*
quit

FTPTest.kix
 Code:
BREAK ON
Shell '%comspec% /c "ftp -i -n -v -s:C:\test\FTPInput.txt" > nul'

A window is opened but no screen output is shown.

Top
#179397 - 2007-08-16 05:20 PM Re: Problem with ftpget( ) UDF. [Re: Witto]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Just found this web page
FTP via ASP without using 3rd-party components
Just some copy and paste without looking up the syntax
 Code:
BREAK ON
$objShell = CreateObject("WSCRIPT.SHELL")
$Catch = $objShell.Run('%comspec% /c "ftp -i -n -v -s:C:\test\FTPInput.txt" > nul',0,-1)

Now launch this with
start wkix32 ftptest.kix
As far as I can see, the script is running silent now.
[Edit]
Here is some more information about the Run method of WScript.Shell
Windows Script Host Run Method (Windows Script Host)
I think you need at least the .NET FrameWork 2.0
[/Edit]


Edited by Witto (2007-08-16 05:40 PM)
Edit Reason: Added link to syntax for wshscript.run

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.074 seconds in which 0.037 seconds were spent on a total of 14 queries. Zlib compression enabled.

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