on 09-01-2011 2:52 PM
HI PI Techies,
I have a scenario where I need to read a File from FTP server based on existence check of another File on the same location of FTP.
Secondly I have a reverse scenario to write a File on FTP server and need to write a Marker File Followed by this File on same FTP Folder.
Can we think of these?
Runtime OS Command before\After Message Processing ( our PI server is AIX OS) ?
( Does it work with FTP server)
or
Adapter Module ( Does it work with FTP)?
Please suggest the possible ways with steps.
Regards,
Anurag
An idea, can be:
READ
- Sender FTP channel based on file existance (file must be empty - at receiver side, do not create empty file)
- OS Script Move file to a "OUTQUEUE" directory
- A sender Channel or directly the OS Script, to trasfer the file
WRITE
- Classical Sender-Receiver File Channels
- An OS script (in Receiver Channel) to create the marker file in destination folder
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anurag,
Read:
1. Sender channel to FTP server to pick the other file and corresponding receive channel to place it in some local directory of PI server
2. In the receiver channel OS command line after message processing call unix shell script which can do a SSH login to FTP server and SCP the file from FTP server to local PI directory
3. Another sender channel to pick the actual file and process it.
Write:
1. Create two receiver channels, one for data file and other file marker file.
2. In the interface determination, add two receiver interfaces for a single sender interface and check the option u201CMaintain order at run timeu201D also create two receiver agreement for each channel.
3. Here the first is for data file and next is for marker file.
4. If you want to write a zero byte file as your marker file you can avoid passing the data from outbound interface to inbound interface.
Hope this will help you.. But here the Unix script actually login to the FTP server and picks the file. Let me know if you need more help on how to do the shell scripting and how to call in command line of channel
Hi,
For the File read, you can try the following approach.
Use the sender file adapter to pick the marker file from the directory and start the interface. Then, use the Java FTP File i\o functionality to pick the actual file. You can either do this in an adapter module or in a Java mapping in the ESR. Java mapping would be better as you'll have more trace and monitoring capabilities than an adapter module. For the ob service interface, remeber to select option "XI 3.0 compliant"
If you decide on an adapter module, then in the process() method, use java file i\o to read the file, convert it to a byte stream and replace this as the payload output from the adapter module.
For the Write functionality, Stephen's suggestion below is the best approach.
Regards
Hi Shiladitya,
Thanks for your reply.
For Sender Case you suggested to start the interface("Use the sender file adapter to pick the marker file from the directory and start the interface.") after picking marker File but how would picking marker File bv a FTP Adapter initiates another scenario to pick the actual Data File From FTP server? What will be the link between two scenarios ?
Please describe more.
Thanks,
Anurag
Hi Stephen,
Thanks for your reply.
For Read Case:
I have never done shell scripting.
Please suggest the way and code to do FTP from shell script through FTP Adapter and pick the file.
Our PI OS is AIX server.
Write:
If I take two receiver interfaces and select maintain order at runtime. Then will it take care that Data File is placed completely before marker File.
Please suggest.
Regards,
Anurag Garg
Hi,
The scenario would be a single scenario. On the sender file adapter, you pick the marker file to start the scenario. Then, either in an adapter module or java mapping, you will retrieve the actual file to replace the payload of the marker file (presume here that the marker file is a zero byte file or one whose actaul payload is irrelevant). You will have two receiver interfaces, one for the marker, other for the actual file. Choose option "maintain order at runtime" so that the marker file is always posted before the actual file.
I Anurag,
For FTP and move to a archive directory, this can be an OS Shell Script sample:
cd /$1
ftp -n -v <<%%EOF%%
open $2
user $3 $4
prompt
asci
cd $5
mput $7*
bye
%%EOF%%
mv $7* /$1/archive
You can pass parameters to $ character, like follow in the File Adapter CommChannel:
sh ShellSampleScript.sh directory_source hostname FTPUsername FTPPassword directory_destination .....
If you need an AdHoc ShellScript.. tell what you want and we can try to accomodate you!
Hi ,
Thanks for reply.
I am looking for shell script with following reuirement:
1) Open FTP connection with inputs( FTP server hostname , userid, password,port) .
2)Take Input for Source Directory and check if MarkerFile.csv exists.
a) If exists, delete MarkerFile.csv and handover the call to FTP Adapter to pick the Actual Data File from FTP server.
b) If doesn't exists. exit the Adapter.
Regards,
Anurag Garg
1) FTP CONNECTION with parameters $1 => Hostname || $2 => Username || $3 => Password
ftp -n -v <<%%EOF%%
open $1
user $2 $3
prompt
asci
bye
%%EOF%%
2) CHECK IF MARKER EXIST $4 => Input File Directory || $5 => Marker Filename (Subsequently, it get file to PI current local directory then, send with the FileAdapter)
cd $4
if [ -s $5 ]; then
mget $5
else
echo NoFile $5
fi
For Read:
You may use a sender channel to reader the marker file and another Sender channel to read the acutal data file and use BPM.
For Write:
This can be achieved by using one receiver channel (depending on the FCC) or two receiver channel.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.