PC Review


Reply
 
 
GregNga
Guest
Posts: n/a
 
      11th Aug 2009
I have a text file, FTPSCRIPT in MYDIR, that contains a series of FTP
commands. Whenever I go to the DOS prompt and execute the command
FTP -s:C:\MYDIR\FTPSCRIPT it works perfectly and FTPs the file successfully

However, When I put it in a .bat file that contains only the command
FTP -s:C:\MYDIR\FTPSCRIPT and click on the .bat file it appears to get in a
loop, displaying the command FTP -s:C:\MYDIR\FTPSCRIPT over and over in the
DOS window and I finally have to cancel it without it ever transferring the
file.

Why does this work OK interactively on the DOS prompt but not in a .bat file
and how can I make it work in batch mode. My objective is to put an icon on
someones desktop so they can click it to run an FTP script
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      11th Aug 2009

"GregNga" <(E-Mail Removed)> wrote in message
news:C68B1FE9-40D2-40C8-A466-(E-Mail Removed)...
>I have a text file, FTPSCRIPT in MYDIR, that contains a series of FTP
> commands. Whenever I go to the DOS prompt and execute the command
> FTP -s:C:\MYDIR\FTPSCRIPT it works perfectly and FTPs the file
> successfully
>
> However, When I put it in a .bat file that contains only the command
> FTP -s:C:\MYDIR\FTPSCRIPT and click on the .bat file it appears to get in
> a
> loop, displaying the command FTP -s:C:\MYDIR\FTPSCRIPT over and over in
> the
> DOS window and I finally have to cancel it without it ever transferring
> the
> file.
>
> Why does this work OK interactively on the DOS prompt but not in a .bat
> file
> and how can I make it work in batch mode. My objective is to put an icon
> on
> someones desktop so they can click it to run an FTP script


There is no difference (or hardly any . . .) between a batch file and the
Command Prompt. If your batch file loops then this is probably because you
have a batch file somewhere that you called ftp.bat. This is bad news - you
must never give a batch file the same name as your system files.


 
Reply With Quote
 
GregNga
Guest
Posts: n/a
 
      11th Aug 2009

You were correct, I renamed the .bat file and it worked perfectly.

Is there any way to supress the display the supression of the FTP commands
on the DOS window or better yet supress/minimize the display of the DOS
window entirely when the FTP command is executed in batch

"Pegasus [MVP]" wrote:

>
> "GregNga" <(E-Mail Removed)> wrote in message
> news:C68B1FE9-40D2-40C8-A466-(E-Mail Removed)...
> >I have a text file, FTPSCRIPT in MYDIR, that contains a series of FTP
> > commands. Whenever I go to the DOS prompt and execute the command
> > FTP -s:C:\MYDIR\FTPSCRIPT it works perfectly and FTPs the file
> > successfully
> >
> > However, When I put it in a .bat file that contains only the command
> > FTP -s:C:\MYDIR\FTPSCRIPT and click on the .bat file it appears to get in
> > a
> > loop, displaying the command FTP -s:C:\MYDIR\FTPSCRIPT over and over in
> > the
> > DOS window and I finally have to cancel it without it ever transferring
> > the
> > file.
> >
> > Why does this work OK interactively on the DOS prompt but not in a .bat
> > file
> > and how can I make it work in batch mode. My objective is to put an icon
> > on
> > someones desktop so they can click it to run an FTP script

>
> There is no difference (or hardly any . . .) between a batch file and the
> Command Prompt. If your batch file loops then this is probably because you
> have a batch file somewhere that you called ftp.bat. This is bad news - you
> must never give a batch file the same name as your system files.
>
>
>

 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      11th Aug 2009

"GregNga" <(E-Mail Removed)> wrote in message
news:5A0E4B9A-6117-48D8-A1EF-(E-Mail Removed)...
> You were correct, I renamed the .bat file and it worked perfectly.
>
> Is there any way to supress the display the supression of the FTP commands
> on the DOS window or better yet supress/minimize the display of the DOS
> window entirely when the FTP command is executed in batch


To really hide an console command you need to invoke it via the Exec command
available in VB Scripts. However, this poses a maintenance problem as you
will now have three files to look after:
a) The VB Script
b) The batch file
c) The script file
This is two files too many. To make this facility robust you should wrap the
whole lot into one single file. Here is how you can do it with a single VB
Script file:

[01] Set oFSO = CreateObject("Scripting.FileSystemObject")
[02] Set oWshShell = CreateObject("WScript.Shell")
[03] sScript = oWshShell.ExpandEnvironmentStrings("%temp%\script.scr")
[04] sLog = oWshShell.ExpandEnvironmentStrings("%temp%\script.log")
[05] sSite = "ftp.quickline.com"
[06] sAccount = "Andy"
[07] sPassword = "andrew"
[08] sFolder = "public_html/Tools"
[09] sFile = "get_.exe"
[10]
[11] Set oScript = oFSO.CreateTextFile(sScript, True)
[12] oScript.WriteLine sAccount
[13] oScript.WriteLine sPassword
[14] oScript.WriteLine "binary"
[15] oScript.writeLine "cd " & sFolder
[16] oScript.WriteLine "get " & sFile
[17] oScript.WriteLine "quit"
[18] oScript.Close
[19] Set oExec = oWshShell.Exec("ftp -s:" & sScript & " " & sSite)
[20] Do While oExec.Status = 0
[21] WScript.Sleep 100
[22] Loop
[23]
[24] Set oLog = oFSO.CreateTextFile(sLog, True)
[25] If oExec.ExitCode = 0 Then
[26] While Not oExec.StdOut.AtEndOfStream
[27] oLog.WriteLine oExec.StdOut.ReadLine
[28] Wend
[29] Else
[30] While Not oExec.StdErr.AtEndOfStream
[31] oLog.WriteLine oExec.StdErr.ReadLine
[32] Wend
[33] End If
[34] oLog.Close

Explanation:
Lines 3..9: You need to set these to suit your environment.
Lines 11-18: They create your script file. You can examine it each time
after running the script.
Lines 19-22: They execute ftp.exe.
Lines 24-30: They generate the log file. This is essential when hiding the
script - without them you'll be flying blind!

You now need to copy the code into c:\Windows\Andrew.vbs, unwrap wrapped
lines, adjust your parameters, then remove the line numbers. You can then
invoke it directly or like so: wscript c:\Windows\Andrew.vbs.


 
Reply With Quote
 
David
Guest
Posts: n/a
 
      12th Aug 2009

Try putting

@echo off

as the first line in your batch file.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


"GregNga" <(E-Mail Removed)> wrote in message
news:5A0E4B9A-6117-48D8-A1EF-(E-Mail Removed)...
> You were correct, I renamed the .bat file and it worked perfectly.
>
> Is there any way to supress the display the supression of the FTP commands
> on the DOS window or better yet supress/minimize the display of the DOS
> window entirely when the FTP command is executed in batch
>
> "Pegasus [MVP]" wrote:
>
>>
>> "GregNga" <(E-Mail Removed)> wrote in message
>> news:C68B1FE9-40D2-40C8-A466-(E-Mail Removed)...
>> >I have a text file, FTPSCRIPT in MYDIR, that contains a series of FTP
>> > commands. Whenever I go to the DOS prompt and execute the command
>> > FTP -s:C:\MYDIR\FTPSCRIPT it works perfectly and FTPs the file
>> > successfully
>> >
>> > However, When I put it in a .bat file that contains only the command
>> > FTP -s:C:\MYDIR\FTPSCRIPT and click on the .bat file it appears to get
>> > in
>> > a
>> > loop, displaying the command FTP -s:C:\MYDIR\FTPSCRIPT over and over in
>> > the
>> > DOS window and I finally have to cancel it without it ever transferring
>> > the
>> > file.
>> >
>> > Why does this work OK interactively on the DOS prompt but not in a .bat
>> > file
>> > and how can I make it work in batch mode. My objective is to put an
>> > icon
>> > on
>> > someones desktop so they can click it to run an FTP script

>>
>> There is no difference (or hardly any . . .) between a batch file and the
>> Command Prompt. If your batch file loops then this is probably because
>> you
>> have a batch file somewhere that you called ftp.bat. This is bad news -
>> you
>> must never give a batch file the same name as your system files.
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
batch file call from a macro - how ? and required batch format VB-rookie Microsoft Excel Programming 3 5th Sep 2008 10:33 PM
calling multiple batch files from within a batch file yawnmoth Windows XP General 3 26th May 2008 06:47 PM
Save batch window msgs to a file from the batch prog Stephen Rainey Windows XP General 3 10th Jan 2007 12:50 AM
Photo Editor Batch supporting batch compression JPG files 29150 Freeware 2 23rd Jun 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:21 PM.