How to ftp and rename file in Unix

Hi Gurus,
I've one requirement where I need to rename the file extension to .xml and read the file.
Here I am pasting my sample code what I've tried
#get the file from remote server
ftp -v -n 10.60.17.111<< EOF
user user user
cd /u01/oratest/gebiz_processed
lcd /usr/tmp
bi
get GEBIZ_ACS_RPO000*.ACK
#mdelete $file
#mv GEBIZ_ACS_RPO000*.* /u01/appltest
#get GEBIZ_SUPP.xml
bye
EOF
echo
cd /u01/oratest/gebiz_processed
file =$(ls -rt GEBIZ_ACS_RPO000*.ACK | tail -1)
if [ -r "$file" ];
then
#HERE ONLY I NEED TO RENAME THE ABOVE .ACK EXTENSION TO .XML
a_file=$(basename $file .ack)
b_file="'$file'"
c_file=$file
echo "Filename: $a_file $b_file" && echo
output=`sqlplus -s /nolog <<-EOT
set pages 0 feed off
whenever sqlerror exit failure;
connect xgbzprod/xgbzprod
exec XGBZ_GLSEGM_XMLTAG_PROC($b_file);
`
echo $output
mv $c_file /u01/oratest/gebiz_inbound
fi
This is my whole script, Steps in this I am performing like :
1> Get the file from another server where the full file name I don't have, since it is suffixed with timestamp, so I called this one like this GEBIZ_ACS_RPO000*.ACK
2> During FTP time, once I copy to my server then I need to delete file GEBIZ_ACS_RPO000*.ACK on that server, I've full permission. How to write that one.
3> Then inside my server I need to change GEBIZ_ACS_RPO000*.ACK to GEBIZ_ACS_RPO000*.XML. How can I write this.
4> Changed extension file name I need to pass in my pl/sql script for processing, which I am taking care.
5> Inside GEBIZ_ACS_RPO000*.ACK, I've xml data only. So I need to change extension of the file to GEBIZ_ACS_RPO000*.XML
I tried to write like above mentioned but I am not getting successful and more over I am not able to rename the file. I know
with command
mv GEBIZ_ACS_RPO000*.ACK GEBIZ_ACS_RPO000*.xml
I can do that but I want it in program way.
Gurus, please help me how to write those steps, and correct me if I am doing wrong above.
Thanks in advance for your help.
Regards
Nagendra
Edited by: 838961 on Mar 30, 2011 12:22 AM

I'd do something like this:
cd /var/tmp
if !wget -c --user=theuser:thepassword 'ftp://10.60.17.111/u01/oratest/gebiz_processed/GERBIZ_ACS_RPO00*.ACK'; then
    echo "FTP fetching failed.' >&2
fi
for fn in GERBIZ_ACS_PRO00*.ACK; do
    new=$(basename "${fn}" .ack).xml
    mv "${fn}" "${new}"
    sqlplus -s /nolog <<-EOF
        set pages 0 feed off
        whenever sqlerror exit failure;
        connect xgbzprod/xgbzprod
        exec XGBZ_GLSEGM_XMLTAG_PROC('${new}');
    EOF
    mv "${new}" /u01/oratest/gebiz_inbound
done
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to clear trc and log files in unix

    How to clear alert log/trace and diag files in unix , database is 11g R2 , is there any way to setup jobs through EM(we are using 11g EM)

    appsguyflorence wrote:
    How to clear alert log/trace and diag files in unix , database is 11g R2 , is there any way to setup jobs through EM(we are using 11g EM)
    Create a script job to rotate / delete old files for example older than 1 month, etc
    Cheers

  • How to run a JAR file in Unix system?

    hi there
    ca anyone tell me how to run a JAR file in unix system or X window, thank you

    You want to create an executable JAR file? You do it in the following way.
    Create a manifest file such as manif.txt and the contents should contain
    Main-Class: foo
    assuming foo is the name of your main class. Then create the jar as follows
    jar cvfm foo.jar manif.txt foo.class
    I hope that helps you!
    you can find more info here http://java.sun.com/docs/books/tutorial/jar/

  • How to edit move rename files in iTunes

    how to edit move rename files in itunes

    I don't like iTunes.
    I don't want iTunes to keep the physical location of my files because they can be on a SD card, or an USB drive and i don't want iTunes to stop me from playing a song because it cannot find it anymore.
    So i would like to use physical files just to upload to iTunes Match and then delete the link to the physical file.
    If needed, iTunes Match will download the file.
    The problem is just that i would like to delete all references to physical files to make iTunes Match download the file only when needed and stop using the first version i had given to it
    maybe i could have a Apple Script to check if there is a physical file referenced and if so delete it to have only the Cloud version     

  • How to download and upload files in Java?

    Hi, everyone
    How to download and upload files in Java? Do you have some references about this issue or some valuable web link�? Thanks!
    Best Regards,
    Hai.Ren

    This is too vague a question, please be more specific. What protocol would you like to use? HTTP? FTP? Something else?

  • Newbie: How To find Core Dump files on Unix?!  URGENT!

    Hi, i would like to know on How To find Core Dump files on Unix?!
    I know they should be found in  /usr/sap/<SYSTEM-ID>/<INSTANZ>/work
    but there are no "core" files and also in tmp is nothing unusual but disk space is totally full.
    So how to find the big files which i could delete to make system running again?!
    can someone provide me with some infos?!
    br

    1. which user i should use to search and destroy?! root-user or SYSID-User?!
    Always use the user with the least permissions to do the job, don't use root if your sidadm can do it. If you want to find / delete SAP files use sidadm.
    2. I found no core files and the harddisk is still 100% full, what files might also cause this problem
    In your first post you wrote that /usr/sap/SID/INST/work dir is full, it is most likely that some trace files got to large. Check for files like dev_*, dew_w0 for example is the trace file of work process 0, dev_disp is the trace of the dispatcher and so on. You either have to increase the size of the filesystem, or find the cause for the growing file. It can be due to an increased trace level.
    3. What on database-side could cause this problems?! can i search for sth here.
    This does not look like a database issue so far.
    4. i was unable to use the given scripts (noob!), what can i do else?!
    Which one, please post what you typed and the error you got.
    Best regards, Michael

  • How to copy and paste file in mavericks

    how to copy and paste file in mavericks?

    Spoombung wrote:
    I actually can't get copy and paste to work in Mavericks!!!
    Is it me, or is there something wrong with it? I can hardly believe this was overlooked....
    Obviously it was not overlooked.
    Select a file, go to the edit menu and choose Copy, open another folder and choose Paste from the edit menu.
    What happened (error messages etc)

  • Open File dialog user can delete and rename files.

    Does any one know if there is a way to prevent a user from deleting and renaming files by right clicking on them in an Open File dialog box?

    Well, the problem is that this isn't a LV dialog box. It's the standard Windows file dialog box and this is the way they work in Windows.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to delete and rename LSMW projects...

    Hello Experts,
    I can't seem to find a way on how to delete and rename my LSMW projects.I dont see any options on how
    to rename it.
    Thank you guys and take care!

    On the LSMW transaction start screen. Goto->Administration. Here you can select your project etc. and rename/delete/copy.

  • How to copy and paste files to Time Capsule

    I thought it could be used as an external disk.
    Do you guys know how to copy and paste files directly into Time Capsule?

    I thought it could be used as an external disk.
    An external disk...also known as a local disk....connects directly to a computer using USB or FireWire.
    The Time Capsule is a network disk, since it connects direct to a network. As such, it s a SHARED network device
    Open a Finder window and look for the SHARED heading on the left side of the window. The Time Capsule icon should appear there. Click on the Time Caspule icon.
    A folder, representing the Time Capsule drive named "Data" (unless you have changed the name of the drive) will appear to the right
    Double click on "Data" to mount the Time Capsule drive on the desktop. You may need to click "Connect As" and enter the Time Capsule device password the first time that you do this.

  • How to read and XSD file in java prospective in NWDS

    Hi !!
    anybody can help me that
    how to read and XSD file in java prospective in Netweaver developer Studio
    Regards
    Abhishek Agrahari

    I guess you can make it more clear...

  • How do I get PSE10 to import and rename files in order?

    When I place my CF card into the reader PSE opens and displays all the photos on the card the problem is they are out of order. I take volleyball photos and use the burst often The files are numbered properly by the camera but PSE seems to get them mixed up. When I import and renamer them PSE thakes them in the order they are shown and they are then renumbered out of order causind many shots to be out of order. I have never had this problem before. I have been using PSE 6 up thru 10 now and this is the first time I have had this happen. Last season I wasusing PSE9 and all my bursts sequences are in purfect order.
    Am I missing something in the settings?

    Hi,
    The problem I have is with the PSE Organizer "Photo Downloader". When I
    plug the CF card from my camera into the card reader on the computer the
    "downloader" opens up and shows thumbnails of the files on the card. At
    this point the files are out of order based on the file numbers applied
    by the camera. I.e.: one sequence looks like this-
    11,12,16,15,14,13,17,18; where 12 thru 16 were a burst. Another
    sequence- 121,120,125,124,122,123; all one burst. As you can see they
    are out of order.  I tried leaving the card in the camera and the same
    thing happens. If I view the photos in /on the camera they are in the
    right order. What has been happening is that I rename and number the
    files as I import them. When that happens the files get numbered in
    sequence as to how they are seen in the "downloader"....this means in
    the examples shown 16 would become 13; 15 becomes 14 ect. This ends up
    mixing up any sequence of shots.
    Once I have the RAW files imported I import them to Lightroom 4 to do
    most of my processing. Here if I choose to arrange by time created I can
    get them in the right order but because the files are rearranged into
    the correct order and since I renamed them on importing the file numbers
    are now out of order. After figuring out what the problem was I can now
    import the files to lightroom without renaming > arrange by time or file
    name> rename> and all seems to be OK. My question is I never had this
    problem before and it was very nice to be able to rename the files at
    import and be done with it.
    I haven't had time to check into it but one thing I'm wondering is is
    there a way to rename the files at import without changing the file
    number? Is there a way to insert the date and text while keeping the
    IMG_Number....i.e IMG001 becomes 2012 09 15_Volleyball_0001 keeping the
    original file number and only inserting a date/name? This would solve
    the whole problem as I could then arrange by file name and all would be
    well.
    Any ideas or help would be appreciated.

  • How to ftp to windows server from unix server

    Hi Gurus,
    Can anybody please guide me how to ftp the files to windows server from unix server. I can do the file transfer via unix by using the shell scripts, where as for windows how can we do that.
    Please advice.
    Regards
    Nagendra

    Hi.
    It's possible many solution.
    1. Setup Ftp server on Windows and use general scripts.
    http://support.microsoft.com/kb/323384
    2. Create general share folder on windows and use smbclient from samba.
    3. Create general share folder on windows and mount this folder to Linux.
    Reagrds.

  • Automator script search document for file name, and rename file to date

    Hi all,
    I'm having a hard time with Automator... and I can't figure out how it's done!
    Searched the web for it a couple of times, spend hours with Automator already, but I guess my need is random!
    The thing is:
    I got a folder with 1066 files, all the files has random names.....
    I got a document (now it's html, but can convert it to PDF or txt or so ever....) with the coressponding random file names in the html.... some words before that there is the date the photo was taken in this format: 08/25/11
    Now I want somehow make automator search that folder each filename... match it in the document with the filename, and rename the files in the folder to the date the photo's were taken.... and that for all 1066 files.....
    anybody a great idea? Some help? I'm a real newby at Automator scrips!
    thanks

    Have you considered A Better Finder Rename 9?
    A Better Finder Rename 9: The Batch File Renamer for Mac OS X
    Otherwise, what you propose seems to be rather like carving the Pieta using a plastic butter knife. But, if you want, here's one example of a rough algorithm to start ...
    * translate the HTML to ASCII text in this format:  filename (date)
    * read one line at a time from the ASCII file
    * for each line, search the folder for the file
    * rename the file according to the (date)
    BTW, you might avoid a strict renaming according to just the date.
    Best luck with this project.
    JJW

  • Moving and renaming files after PSE has uploaded them

    I use PSE 7
    I have many folders  (50+) and perhsps file names  ( few thousdand)  that after uplaoding all of them into PSE and tagging about half I am consdering remaning some of them and also combine some folders or just renaming some folders
    any  way to do this with in PSE by jsut doing a folder at a time ( change folder name)  and change file names all at once.
    Would it be easyer to start all over by deleting all images in PSE but not on the disk then reload it all, will the tags still  show up on the photo AND all the tags icons on the side bar be their after
    any help greatly appreacted, I should have done this before starting to work in PSE
    thanks
    Mike

    I think the biggest thing people miss understand about the Organizer  is you no longer have to be concerned with folders or where the photos are located. The beauty of Tags allows you to locate your photo by various methods that you can not do with folders. You can have a tags for location, event and peoples name on the same photo and  you can locate it in your Organizer catalog by selecting any combination of the tags you have assigned. You can not do that with folders. As an example you can find a photo of Jane, from California, at your graduation party.
    Adobe does a poor job of highlighting the advantages of creating tags. The original creator of Album that was later changed to Organizer, Michael Slater, wrote a book on how and what you should think about before creating tags. Unfortunately, he no longer works for Adobe and the book was written for PSE 3. And a lot has changed since then. But the basic concept of using tags verses folders is still applicable and the Chapter is and well worth the price of the book which is still available from Amazon.  http://www.amazon.com/Organize-Photos-Adobe-Photoshop-Elements/dp/0321246969

Maybe you are looking for