command line - trying to transfer a file from my computer to a unix server

07
2013-09
  • Tapan

    I m trying to automate the deployment process wherein i follow the following steps-

    1.Run a Ant Script to build a .ear file

    2.Login to the unix server using putty(SSH Connection) providing the login credentials.

    3.Then i enter the superuser credentials for write permissions.

    4.Rename a existing file in the server and then transfer the file from the local system to unix server.

    My 1st thought was PSCP or PSFTP,but I have no idea how to provide these super user credentials.

    I want a command prompt script so that i can save it as .bat file.Plzz help

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    transfer file from unix to windows?
  • Mohammad AL-Rawabdeh

    i want to transfer file from unix server to windows 2003 server i download copssh on windows 2003 and openssh is already installed in unix ... i execute the following command :- scp -r /file_in_unix/ user@windows_hostname:\c:\\

    the following output appear in unix screen :-

    100% |***************************************************************| 562 00:00

    but when i go to see file in c drive i don't find anything :(


  • Related Answers
  • David Spillett

    The destination path looks wrong - to most unix shells the forward slash is an escape character not a path marker, so I'm guessing the file has dropped into the SSH user's home directory with an odd filename.

    IIRC copssh is based on cygwin, so what you probably needed to run is:

    scp -r /file_in_unix/ user@windows_hostname:/cygdrive/c/
    

    An alternatives to copying to a SSH service on the Windows machine is to use a GUI client like WinSCP on the Windows box to login to the Unix machine and pull the files over that way - though this is not suitable if you are trying to automate the process.

    If you have privileged access on the unix machine (i.e. you are, or can become via sudo or similar, root) and have the relevant support installed you could just copy the files onto a Windows share. You don't say what Unix you are using. For Ubuntu and similar checking that support is present and installing it if not can be done with sudo aptitude install smbfs, you can them mount a Windwos share with something like sudo mount -tcifs //11.22.33.44//sharename /mnt/tmp -ousername=WindowsUserName (where 11.22.33.44 is the IP address of the windows machine, depending on your network setup you may be able to refer to the machine by name rather than address). Once you've done that you can just use the basic file management tools (cp, mv, ...) to interact with that Windows share and call umount /mnt/tmp when you are done. You might want to choose a more meaningful mount point name than /mnt/tmp. You can leave the share mounted, of course, if the transfer of the data is to be automated/scheduled. This method does assume that the Unix machine can see the Windows machine's fileshares through any firewall arrangements that may exist between them.

  • Olfan

    You can also do it the other way round and pull files from the Windows side instead of pushing from the Unix side. Have a look into tools like WinSCP which is a graphical tool for SCP file transfers giving you a choice between the Windows Explorer or Norton Commander look and feel, both of which should be intuitive to you. Once logged in, you can navigate to the files of interest "the Windows way" and drag and drop them to wherever you want them.