FTP Import

nikhiltoor27
Member Posts: 8
Hi All,
This is the snippet of code that I've written to import an order from FTP for further processing in Navision. The same script which is generating through this code is running completely fine if use command prompt to execute each step manually. But if I am executing this then the files are not imported from the FTP.
RetailSetup.GET;
SalesFile := ENVIRON('TEMP') + '\' + 'FTPScript.bat';
CLEAR(FTPScript);
FTPScript.CREATE(SalesFile);
FTPScript.WRITEMODE(TRUE);
FTPScript.TEXTMODE(TRUE);
FTPScript.WRITE('@ECHO OFF');
FTPScript.WRITE('CD ' + ENVIRON('TEMP'));
FTPScript.WRITE('> script.ftp ECHO open ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('>>script.ftp ECHO USER ' + RetailSetup."FTP User ID");
FTPScript.WRITE('>>script.ftp ECHO ' + RetailSetup."FTP Password");
FTPScript.WRITE('>>script.ftp ECHO CD ' + 'OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO prompt');
FTPScript.WRITE('>>script.ftp ECHO bin');
FTPScript.WRITE('>>script.ftp ECHO lcd ' + RetailSetup."Magento Order File Import Path");
FTPScript.WRITE('>>script.ftp ECHO mget ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/Archive/');
FTPScript.WRITE('>>script.ftp ECHO mput ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO mdel ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO Bye');
FTPScript.WRITE('FTP -s:Ftpscript.ftp -n ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('TYPE NUL >script.ftp');
FTPScript.WRITE('DEL /F script.ftp');
FTPScript.WRITE(':retry_del');
FTPScript.WRITE('DEL "' + SalesFile + '" > NUL');
FTPScript.WRITE('if exist "' + SalesFile + '" goto retry_del');
FTPScript.CLOSE;
IF ISCLEAR(lAutWshShell) THEN
CREATE(lAutWshShell);
lBlnWaitOnReturn := TRUE;
lAutWshShell.Run(SalesFile,lIntWindowType,lBlnWaitOnReturn);
CLEAR(lAutWshShell);
Can please someone suggest what's wrong with this code.
This is the snippet of code that I've written to import an order from FTP for further processing in Navision. The same script which is generating through this code is running completely fine if use command prompt to execute each step manually. But if I am executing this then the files are not imported from the FTP.
RetailSetup.GET;
SalesFile := ENVIRON('TEMP') + '\' + 'FTPScript.bat';
CLEAR(FTPScript);
FTPScript.CREATE(SalesFile);
FTPScript.WRITEMODE(TRUE);
FTPScript.TEXTMODE(TRUE);
FTPScript.WRITE('@ECHO OFF');
FTPScript.WRITE('CD ' + ENVIRON('TEMP'));
FTPScript.WRITE('> script.ftp ECHO open ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('>>script.ftp ECHO USER ' + RetailSetup."FTP User ID");
FTPScript.WRITE('>>script.ftp ECHO ' + RetailSetup."FTP Password");
FTPScript.WRITE('>>script.ftp ECHO CD ' + 'OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO prompt');
FTPScript.WRITE('>>script.ftp ECHO bin');
FTPScript.WRITE('>>script.ftp ECHO lcd ' + RetailSetup."Magento Order File Import Path");
FTPScript.WRITE('>>script.ftp ECHO mget ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/Archive/');
FTPScript.WRITE('>>script.ftp ECHO mput ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO CD ' + '/OutBox/Orders/');
FTPScript.WRITE('>>script.ftp ECHO mdel ' + '*.csv' );
FTPScript.WRITE('>>script.ftp ECHO Bye');
FTPScript.WRITE('FTP -s:Ftpscript.ftp -n ' + RetailSetup."FTP IP Address");
FTPScript.WRITE('TYPE NUL >script.ftp');
FTPScript.WRITE('DEL /F script.ftp');
FTPScript.WRITE(':retry_del');
FTPScript.WRITE('DEL "' + SalesFile + '" > NUL');
FTPScript.WRITE('if exist "' + SalesFile + '" goto retry_del');
FTPScript.CLOSE;
IF ISCLEAR(lAutWshShell) THEN
CREATE(lAutWshShell);
lBlnWaitOnReturn := TRUE;
lAutWshShell.Run(SalesFile,lIntWindowType,lBlnWaitOnReturn);
CLEAR(lAutWshShell);
Can please someone suggest what's wrong with this code.
0
Answers
-
Take a look at this post http://forum.mibuso.com/discussion/54942/ftp-upload-download
A little bit different.0 -
FTPScript.WRITE('FTP -s:Ftpscript.ftp -n ' + RetailSetup."FTP IP Address");
should that be ?
FTPScript.WRITE('FTP -s:script.ftp -n ' + RetailSetup."FTP IP Address");\\The truth exists in seven versions.0 -
Here is another solution using ftp dotnet type to transfer files.
dynamicsuser.net/nav/b/ara3n/posts/moving-files-in-nav-with-ftp0 -
The writer is deeply involved in the writing process http://www.buy-essay-online.com/ and collects information, evidence and facts for a high-quality essay.-2
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions