Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Line Mystery? 2

Status
Not open for further replies.

AlexCuse

Programmer
Apr 13, 2006
5,416
US
Hi All,

I have an application that runs every day. The first step in processing is to write an FTP script to a directory and then run it through the command line. For months now it has been running alright (although once in a while it stalls at the command line and I need to restart machine to get it to work).

This morning I tried restarting/shutting down my computer at least 10 times and it still was not working. I ran the script manually through the command line and confirmed that it was being written correctly, so I suspect that some change has been made and the machine is no longer allowing access to send data to the command line.

Has anyone had an experience like this? Any help would be greatly appreciated.

Thanks a lot,

Alex

PS I am running access 2000
 
Nevermind. SQL Server Enterprise Manager seems to be the culprit. They were doing network maintenance last night and there must have been a problem when I shut it down. After going in and out of EM everything seems to be working. Although any ways around this problem in the future would still be appreciated.
 
Can you post the script you are running so we can take a look. Also how is the scheduling being handled? Standard winxp scheduled task?

Thanks


Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
This process is being run manually because it is dependent upon when we receive data from a vendor who has been inconsistent with their emails. This is the basic script and it is repeated for each filename. The script is being generated fine, the problem is with sending the command (ftpscrpt -f drive:\location\scriptname.scp) to the command line.

Code:
user (user)pass (pass)connect (IP.Address)
LCD a:\Local\Directory\Write\Tocd FTP/Folder
get Filename.PGP 
a:\Local\Directory\Write\To\Filename.PGP 1

Let me know if you have any tips for getting the command in there.
 
I am still having no luck with this (It ran on the day I posted but has not run properly since), and I'm starting to wonder if it's a problem with my computer? I have had trouble trying to run the application from other machines as well. Because the FTP Script runs fine manually it has to be something to do with Access's ability to communicate with the command window, right? Here is the code sending it to the command window, for what it's worth...

Code:
Public Function OpenCmdWindow()
Dim ReturnAppCode As Integer
Dim ScriptPath, ScriptFileName, ScriptExecutionLine As String

ScriptPath = "C:\"
ScriptFileName = "GetFileFTP.scp"


ScriptExecutionLine = "ftpscrpt -f " & ScriptPath & ScriptFileName & "~" & "Exit~"

 ReturnAppCode = Shell("cmd")
 
 MsgBox "Script file Build Complete, Run Script" 'this messagebox must be here to activate the window properly
 
 AppActivate ReturnAppCode ' window title that could be used instead of ReturnAppCode -->"c:\WINDOWS\system32\cmd.exe"

 SendKeys (ScriptExecutionLine) 'run the scripting routine in the command window
 
 OpenCmdWindow = ReturnAppCode

Any ideas on how I could make this work again would be greatly appreciated.

Also- Looking at this for the 80th time made me think of another possible problem. Could it be that the msg box is not giving me a long enough delay to allow the command window to open properly?

Thanks in advance for your help,

Alex

 
How about this?
Code:
ScriptPath = "C:\"
ScriptFileName = "GetFileFTP.scp"


ScriptExecutionLine = "ftpscrpt -f " & ScriptPath & ScriptFileName

ReturnAppCode = shell(ScriptExecutionLine)

 
I am actually just about to run the application, so I will try it. THat's a really good idea though I can't believe I didn't think of it. I do most of my work in SQL and am kind of new to VBA.
 
again, it works normally to type the result of "ScriptExecutionLine" in the shell, but for some reason it isn't working through the application. I get a window labeled "help" on the taskbar with these contents:

Commandline syntax:
ftpscrpt -?
ftpscrpt [options]
Options:
-p profile_name
-u userid
-w password
-c account
-b Specifies binary mode, otherwise ascii is assumed.
-f script_file_name
-q ssl usage 1-3


here is the function I am using now:
Code:
Public Function OpenCmdWindow()
Dim ReturnAppCode
Dim ScriptPath, ScriptFileName, ScriptExecutionLine As String

ScriptPath = "C:\"
ScriptFileName = "GetRAAFTP.scp"



ScriptExecutionLine = "ftpscrpt -f " & ScriptPath & ScriptFileName

 ReturnAppCode = Shell(ScriptExecutionLine)

Thanks for all your help, I think I'm on the right track now at least...
 
So what it looks like to me is, ftpscrpt doesn't like the format of the command line it's getting. What does

debug.print ScriptExecutionLine

look like?
 
I've tried that, and I get

ftpscrpt -f C:\GetRAAFTP.scp

this is also what I was running in the shell, and it is working alright from there. Let me know if you've got any ideas.
 
Just a silly thought.
Code:
Dim ScriptPath [COLOR=red]As String[/color], ScriptFileName [COLOR=red]As String[/color], ScriptExecutionLine As String

... in case passing them as Variant is mucking things up in the between spaces.
 
Still no dice. This is driving me nuts, up until last week it was working fine. I even tried

Code:
ReturnAppCode = Shell("ftpscrpt -f c:\getRAAFTP.scp")

but to no avail. Is there something wrong with the Shell command?
 
Easter egging:

That's exactly how you type in the command line if you run this manually from a command prompt, right?

What do you get if you create a faulty script and try to execute it from the command line?

What's the last change date on the script itself?
 
Ok here goes-

1. Yes, when I run it from shell (or command window) it is typed exactly as the debug.print comes out.

2. I tried from shell to run "ftpscrpt c:\getRAAFTP.scp" and that even worked. Tried modifying ScriptExecutionLine in routine to these results and got the same help box.
2a. If I try to load a script that is not there I get command window saying "Failed to load script"

3. The script is modified every day by the same application.

Are you aware of any problems that Access has communicating with the shell or command window? Thanks so much for all your help, I'm glad to know that I'm not insane.
 
I'm not aware of such problems, but let's revisit 2a. What if, instead of a script that isn't there, you try to run a script that is a valid filename, but isn't a working script. I.e., put something unacceptable on the first line to intentionally break the script, and see what happens.

Have there been any changes recently to the application which modifies the script?
 
I don't know what you mean by intentionally break the script, but I tried putting all x's on the first line (script ran successfully) and I tried running a random text file (it tried to run in command window as an ftp script). When I tried both of these in application I got the same results.

No changes have been made to the script generation module.
 
Just another thought. When you run the script through the code, are you POSITIVE that the script is not running. In other words have you check to see the items effected by the script are not effected.

I think there is a parameter to the shell command to make it run maximized instead of the default hidden.

i.e. ReturnAppCode = shell("ftpscrpt -f c:\getRAAFTP.scp",vbMaximizedFocus)

If you run it this way, does the cmd window show up and if so does the script appear to be running?

This is truley weird.

Andy



Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
That's what I meant by intentionally breaking the script. We've established that ftpscrpt.exe is receiving the command but failing to interpret the command line arguments properly, and that the error is in either how VBA is passing them or in how Windows is passing them.

In your object browser, if you select the VBA object, what's its filename? E.g., mine's VBE6.DLL. Perhaps that has become corrupted?
 
positive. It gives me command window open to My Documents (or the help file when I try running in shell). I have spent the entire day trying to get this to work and it is driving me absolutely nuts. Thanks for being so patient with me.
 
It's called VBE6.DLL. How can I tell if it's corrupted? And if it was wouldn't other VBA apps be giving me problems?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top