11 Replies Latest reply: Sep 24, 2012 12:24 AM by Joe007 RSS

    How to copy a file from one folder to another folder in Linux

    Joe007
      Hello everyone,

      Oracle forms 11g 11.1.2.0.0
      OS: Oracle Linux

      We use webutil to upload files to the application server from the client machine, and stores them in a folder named JOB_DOCS on the application server (This folder is created as a databse directory too). File types are JPEG, GIF, PDF, TXT, BMP, DOC, XLS etc...
      At a later stage when the user tries to view the uploaded documents, this was not getting displayed on the screen

      on our windows server, when the user clicks on the print button we copy the file from the JOB_DOCS folder to the forms\java folder using the below command

      HOST('COPY ' ||d:\JOB_DOCS\test.pdf||' '||'c:\oracle\middleware\as\forms\java\test.pdf ,NO_SCREEN);

      once the file is under the forms\java folder then it is getting displayed on the screen to print or save, and later we remove the file from forms\java folder.

      But my problem here is, recently we have installed our application on Oracle Linux server, and we have JOB_DOCS folder there, and the users can upload files to this folder also. How can we copy the file test.pdf from JOB_DOCS to forms/java in linux?
      And what could be the reson for the document cannot be accessed from the folder where it is saved? We tried giving folder permissions, adding the folder to PATH variable etc.
        • 1. Re: How to copy a file from one folder to another folder in Linux
          Osama_Mustafa
          IF YOU NEED TO COPY THE FILE :

          cp /u01/app/filename <new-location>

          copy folder

          cp -r /u01/app <new location>

          move folder use

          mv


          google and read .
          • 2. Re: How to copy a file from one folder to another folder in Linux
            Veeresh.S
            For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you've already tried to copy a directory with cp, you've probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means "copy recursively":
            $ cp -r dir1 dir2

            The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1.

            When renaming directories, you use the mv command exactly the same way as with files:
            $ mv dir1 dir2

            When dealing with directories, mv works a bit like cp does. If dir2 doesn't exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.

            ref http://www.tuxfiles.org/linuxhelp/dirman.html
            • 3. Re: How to copy a file from one folder to another folder in Linux
              kuljeet singh -
              But my problem here is, recently we have installed our application on Oracle Linux server, and we have JOB_DOCS folder there, and the users can upload files to this folder also. How can we copy the file test.pdf from JOB_DOCS to forms/java in linux?
              use cp inplace of copy in linux
              And what could be the reson for the document cannot be accessed from the folder where it is saved? We tried giving folder permissions, adding the folder to PATH variable etc.
              could be due to permission or ownership issue,post error msg and file permission/ownership
              • 4. Re: How to copy a file from one folder to another folder in Linux
                Joe007
                That can be done in terminal, but how to use the same in forms?

                are you saying that the below command should work in Linux?

                HOST('cp ' ||'/u01/JOB_DOCS/test.pdf'||' '||'/u01/forms/java/test.pdf',NO_SCREEN);

                I had tried this.......
                • 5. Re: How to copy a file from one folder to another folder in Linux
                  Paul M.
                  HOST('cp ' ||'/u01/JOB_DOCS/test.pdf'||' '||'/u01/forms/java/test.pdf',NO_SCREEN);

                  I had tried this.......
                  ... and ?
                  • 6. Re: How to copy a file from one folder to another folder in Linux
                    Osama_Mustafa
                    Joe wrote:
                    That can be done in terminal, but how to use the same in forms?

                    are you saying that the below command should work in Linux?

                    HOST('cp ' ||'/u01/JOB_DOCS/test.pdf'||' '||'/u01/forms/java/test.pdf',NO_SCREEN);

                    I had tried this.......
                    Ok you tired this and maybe its not working but Post error that appear to you should we guess it for you ???

                    Check these link

                    Running Copy command from Forms 6i
                    http://www.orafaq.com/forum/t/159081/0/
                    • 7. Re: How to copy a file from one folder to another folder in Linux
                      Joe007
                      sorry about that....
                      when i run this command from forms, i am not getting any error messages...let me work on it and will defenitly come back to you soon.......thanks for your kind support
                      • 8. Re: How to copy a file from one folder to another folder in Linux
                        Joe007
                        Hi I tried HOST('cp /docs/JOB_DOCS/test.pdf /docs/test.pdf'); //this is done on a button press

                        It is not even copying the file to one level above the current folder. But the same command works fine in the terminal.
                        I am not gettting any error messages also.......

                        since 'cp' is an operating system command, it should work right?
                        • 9. Re: How to copy a file from one folder to another folder in Linux
                          Paul M.
                          I tried HOST('cp /docs/JOB_DOCS/test.pdf /docs/test.pdf');
                          Try
                          HOST('/bin/cp /docs/JOB_DOCS/test.pdf /docs/test.pdf');
                          • 10. Re: How to copy a file from one folder to another folder in Linux
                            Dude!
                            When you create directory, the default permissions are 755 or rwxr-xr-x. For example:

                            su - root
                            mkdir /docs
                            ls -ld /docs
                            drwxr-xr-x. 2 root root 4096 Sep 23 17:46 /docs

                            These permissions will allow anyone to list /docs, but will only allow root to create or copy files inside the /docs directory. Your application is most likely not running as root, and hence permissions are restricted by the user account under which the app is running. Perhaps you can correct the problem by assigning groups and setting appropriate permissions. However, there is not enough information your post to be able to pinpoint the issue.
                            • 11. Re: How to copy a file from one folder to another folder in Linux
                              Joe007
                              Helloooo

                              Many thanks for all of yours comments and suggestions.........
                              Dude's comment helped me to resolve this.....
                              This was a problem with the directory permissions only.......initially i told that i checked permissions....so many of you might have ignored this....sorry for that.....even i was not aware of what Dude said in his comment.....earlier i tried giving permissions by right clicking on the directory and moving to the permissions tab, but this wasnt working.....this JOB_DOCS directory was created by selecting new folder from the file menu. I removed the directory and created this again through terminal window as weblogic user. Now the HOST('cp docs/JOB_DOCS/test.pdf /forms/java/test.pdf') is working perfectly.....
                              Thanks everyone.......