Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Batch file code to connect ftp server and run some process

Posted on 2012-08-12
25
Medium Priority
?
1,728 Views
Last Modified: 2013-01-22
Hi,

I am looking for the code to write a batch file to automate a process to run every hour from windows 7 client or from the server itself.

The logic is : connect to the ftp server using username/pwd, open a folder, copy the csv file created recently and save in another location with a filename <Test.csv>

Once this step done, i have to run a exe program which contains the steps using mouse click ( OPEN CSV file from saved location previously - EXPORT - OK )

As final step, to run some other batch files written already.

Any helps, is that possible to do ?
0
Comment
Question by:kriiis
  • 10
  • 10
  • +1
22 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 1400 total points
ID: 38286216
Of course.  Late now but there are some examples of how to ftp on my page here:

http://scripts.dragon-it.co.uk/links/batch-ftp-scripting

I normally use "Method 3" myself.

You want these commands together with the other bits from the site (with echo in front if you use this method I say):

echo open x.x.x.x
echo user username password
echo lcd C:\your\local\dir
echo cd /remote/dir
echo bin
echo get test.csv
echo quit

or similar.  You can then run an exe against the test.csv etc. as needed.  If you can't control it from command line switches or the like then look at a program called Auto It.  You can write simple scripts to click the relevant buttons etc, compile it to an exe file and then include that in your batch file.

Steve
0
 

Author Comment

by:kriiis
ID: 38289413
acutally the exe is not a office pack.. it is another software.. is that possible to control the mouse clicks by script ? is there any examples codes ? cause i am new to this scripting , batch command stuffs..
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 1400 total points
ID: 38289796
Yes auto-it can control anything.
http://www.autoitscript.com/site/
Steve
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:kriiis
ID: 38300221
@dragon-it, I wrote some simple code like this :

Run("test.exe")
MouseClick ("left", 298,218)
MouseClick ("left", 491,512)

I have some issue for second mouse click.
1st mouse click clicks on the boutton open, this action will open another window with 3 buttons, i want to click the 3 button to open a file, so in my code i entered the value ( 491,512).
The problem is first mouse click works, but second fails to click the button. any ideas why this happens ?

The exe file is developped in java, probably, for information.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38300237
Good question...  you can do something with ControlClick I think:

ControlClick("window title", "", "[CLASS:Button; TEXT:Buttons text]")
0
 

Author Comment

by:kriiis
ID: 38301499
Run("test.exe")
MouseClick ("left", 298,218)
MouseMove (780,518)
ControlClick ( "Window title", "text in window","left", 786,515)

Here is my code, the mouse curson commes to the button open ( see screenshot ), but doesn't do any action.

I do anything wrong ?
Window-screen.png
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38301559
Good question.  There is another parameter on the control click before the x,y which is number of clicks.... try a 1, before the co-ords.  Not on machine I can test an autoit on at the mo. sorry to check more and haven't used it regularly for a few years.

Did you try it like I suggesed with more like this... with the title of the popup window.

ControlClick("title", "", "[CLASS:Button; TEXT:Open")
0
 

Author Comment

by:kriiis
ID: 38301768
Yes i tried as you suggested on previous comment but It doesn't reacts. I will try this one and let u know.
If you the screen shot the button befor open is selected. It's shaded by blue. Is that something related ?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38301909
I wonder if maybe it is still focused on the other window.   Can you show use the rest of the buttons / window titles perhaps - can send to email address in my profile (click dragon-it link) if you don't want to post it for some reason.

Steve
0
 

Author Comment

by:kriiis
ID: 38302362
Hi !steve, its done.. you got the screenshot.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38303035
Ok, got it but shutting down for night.  Will look at it tomorrow.

Steve
0
 

Author Comment

by:kriiis
ID: 38303634
Thank u
0
 

Author Comment

by:kriiis
ID: 38304990
Hi Steve, i tried by adding 1 before co ordin... but same result, it doesnt clicks on the button.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38305750
Hmm how about going the keyboard route then.  Assuming there isn't a keyboard shortcut (e.g. Alt X) for the button does it work if you do

tab tab space
or tab tab enter

If so how about:

WinActivate ("Charger un enregistrement")
Send("{TAB 2}{SPACE}")

or

WinActivate ("Charger un enregistrement")
Send("{TAB 2}{ENTER}")

Steve
0
 

Author Comment

by:kriiis
ID: 38305794
Steve there is no keyboard shortcut. :( I already tried.
Another thing I tried is when I set mouse click value to 2 and move over the desktop icons and also at the window I need it works. But doesn't select the button automatically that I need.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38305830
Is this a proper app or a web page / java applet or something?
0
 

Author Comment

by:kriiis
ID: 38305858
Not a web page. It is an exe file. Needs java to be installed in the client. but I am unable to say it is java applet
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 38306898
Might want to try Robo-FTP.  It has a scripting interface designed to automate this sort of process.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 38786751
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38786752
Question was to get a file from CSV then automate a process.  I gave a working example of getting file by ftp which I believe he has working.
The next part was to automate an unknown exe.  Autoit should be able to do it and suggested many ways of doing this but without the EXE in front of us difficult to know what it/isn't clciking.

Accept: http:#a38286216  re: FTP
Accept: http:#a38289796 re: Autoit
0
 

Author Comment

by:kriiis
ID: 38789500
To follow the comment, i havent yet implemented the solution to automate. I am still looking for..
Drgon It comments are helpful, but doesnt fulfill my expectation.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38789551
happy to carry on, wasnt me who started to close this but got no feedback for 5 months...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question