How do I copy a file to a remote server using runtime exec - plz Help!

Hi,
I am trying to copy a file to a remote server using a runtime exec command as follows:
Runtime.getRuntime().exec("scp "+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_JAR)+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_JAR_NAME)+".jar "+" "+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_USERNAME)+"@"+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_URL)+":"+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_JAR));
Problem is this statement does not execute, as when I try it directly on command line, it requests for a password. Any suggestions on how I can get rid of that? I think I might have to configure my ssh_config file, but when I did some "Googling", I found the configuration settings of a ssh2_config file. I tried those (changing it to Host-based Authentication), but it didn't recognise them. Please help, this is so urgent!
Regards,
Simz

Don't use Runtime.exec (or ProcessBuilder) for this. Check out JSch at JCraft (or some other Java SSH API.

Similar Messages

  • How to execute a batch file on different remote server using TFS Build

    I have a build server and have 2 web servers. I am deploying using TFS Builds. Now, I have a requirement to execute a batch file which is kept on these 2 web servers. i.e. C:\MyBatch\CreateMe.bat
    After my build is successful, I need to execute this batch from the build server.
    Note, I cannot make any shared folder.

    Hi Sameer, 
    Thanks for your post.
    What’s the version of your TFS?
    How do you deploy solution using TFS Build, run MSBuild deploy command or using Release Management?
    That C:\MyBatch\CreateMe.bat file stay on your two web server machines separately? 
    If you want execute this bat file on your two web server machines separately using build process template, you need configure your web server machine as build agent, then add the InvokeProcess activity in build process template to run the bat file on build
    agent machine after build, please refer to Hari’s answer reply in this post:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/b8bcb19f-1296-441c-8356-e701b949445a/tfs-2010-how-to-execute-a-batch-file-after-build?forum=tfsbuild.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do I copy my files from my host server acct to my (new) hard drive?

    I recently purchased a new
    laptop after a crash.  I was able to install DW (CS3)
    and my files are all intact.  But I need to put the files on my hard drive so that I can edit them offline.  As it is, everytime I open DW, I'm connected to the host.  Previously, I could connect when I was ready to post.   So, the question is: how do I transfer my images and html web pages to my hard drive. Once that is done, I should be able to work offline, right, from my computer.  Thanks.

    Define a Local Site folder in DW.  This is where your site files will be stored locally.
    Open DW, hit GET (Down Arrow) to download files and folders from your remote server.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • How to upload a current file to the remote server in Dreamweaver?

    I am trying to transfer an html file from FrontPage to the server via Dreamweaver, but it absolutely refuses to upload. Help!

    Nobody can know anything. You are not providing any system information, what version of DW you use, what the remote server actually is. and since this is a DW question, ask in their forum with the proper information included.
    Mylenium

  • How to wait till the end of DOS program started using Runtime.exec(cmd)?

    In my Java program I need to call two DOS batch programs namely call.bat and start.bat. First I need to start the batch program call.bat and once that program is completed, I need to call the other batch file start.bat.
    The piece of code which I am using is:
    public static void ExecuteScripts(){
    try {
    \\Start the first batch program call.bat
    Process p = Runtime.getRuntime().exec("cmd /c start .\\scripts\\call.bat");
    p.waitFor();
    System.out.println("Exit value "+p.exitValue());
    \\Start the second batch program run.bat
    Process p1 = Runtime.getRuntime().exec("cmd /c start .\\scripts\\run.bat");
    catch (Exception e) {
    e.printStackTrace();
    For this piece of code it starts the first batch program(i.e, call.bat) in a command prompt and immediately it starts the second batch program (i.e, run.bat) in another command prompt. So it runs both the batch programs simultanesously. But what I wanted is that my program should wait till the first batch is executed and then start the second batch.
    Please tell me how to wait between these two runtime commands in JAVA
    With regards,
    C.Chenthil.
    -------------------

    Hi everybody thanks a lot.
    I got a solution from another forum. Kindly find the solution
    public static void ExecuteScripts(){
    try {
    \\Start the first batch program call.bat
    Process p = Runtime.getRuntime().exec("cmd /c start/wait .\\scripts\\call.bat");
    p.waitFor();
    System.out.println("Exit value "+p.exitValue());
    \\Start the second batch program run.bat
    Process p1 = Runtime.getRuntime().exec("cmd /c start/wait .\\scripts\\run.bat");
    catch (Exception e) {
    e.printStackTrace();
    Process p = Runtime.getRuntime().exec("cmd /c start/wait .\\scripts\\call.bat"); is the switch that served my purpose.

  • Send file to a remote server

    how do I send a file to a remote server?
    I attached my code so you can see what is missing.
    the purpose of it is to send a server all the files in a directory + the name of directory + how many files there are
    URL url=null;
                    try {
         url= new URL("www.<server's address>");
                     }catch (MalformedURLException e) {
                      try {
          // Construct data
            File[] picFiles= path.listFiles(new pictureFileFilter());
            int numOfFiles= picFiles.length;
            String setName= path.getName();
            String data= ("setName= " + setName);
            data += ("&" + "numOfFiles= " + numOfFiles);
           String[] allFiles= new String[numOfFiles];
           for (int i=0; i<numOfFiles; i++) {
                 FileInputStream FIS= new FileInputStream(path);
              //WHAT TO DO HERE?!?!?
         data += ("&"+"allFiles="+allFiles);          
            // Send data
                       URLConnection conn = url.openConnection();
                      conn.setDoOutput(true);
                      conn.setDoInput(true);
                      OutputStreamWriter wr = new 
                                                 OutputStreamWriterconn.getOutputStream());
                      wr.write(data);
                      wr.flush();
            // Get the response
                        BufferedReader rd = new BufferedReader(new       
                                                InputStreamReader(conn.getInputStream()));
                       String line;
                        while ((line = rd.readLine()) != null) {
                                    //what to do with response (this part is OK)
                     new GoodBadMassage(line);
                         wr.close();
         rd.close();
             } catch (Exception e) {
             }~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    another thing-
    is the line --- conn.setRequestProperty("content-type","binary/data");
    replace the need in ---
    String data= ("setName= " + setName);
    OutputStreamWriter wr = new utputStreamWriter..
    wr.write(data);
    I'm not sure what does is do (setRequestProperty)
    THANKS!!

    You start out by trying to use a malformed URL (it doesn't start with a protocol). This suggests to me that you haven't thought about the natural question: what kind of server software is running on that server that will accept files?

  • How can I copy mp3 files from my Itunes library to an SD card for use in a non-apple phone?

    How can I copy mp3 files from my Itunes library to an SD card for use in a non-apple phone?  I can physically copy the tunes as mp3's but the phone does not seem to be able to play all of them.   Do I need to copy an entire album or can I just pick & choose individual songs?   The phone is question is an LG running who knows what for an operating system.

    AAC is Advanced Audio Coding.  Basically it's a format that sounds better than MP3 but doesn't take up as much space as a lossless format (like you'd have on a CD).  More than likely you've had that encoding turned on when you ripped your music into itunes (it's the default encoder).  Therefore your LG phone won't play them.
    You need to turn off the AAC format by going to the iTunes menu, Preferences, General (at the top), then clicking the "Import Preferences" button.  Change the AAC Encoder to MP3 Encoder.  After that you'll have to make MP3 copies of your songs by right clicking them and selecting "Create MP3 Version."  You'll get a copy of the song that should transfer to your SD card and have MP3 encoding.  Hopefully your phone will play that.

  • I made an iPhoto book and the file is on my husband's macbook pro.  How do I copy that file so I can have it on my iMac?

    I recently made an iphoto book on my husbands macbook pro and want to move the file to my imac.  How do I copy the file and place it on my imac?  Thank you in advance.

    You can not. You can only move the entire library. Books do not exist seperate from the database. You can duplicate the library and delete very thing except the book to make it smaller
    LN

  • IMac is not booting - How can I copy my files to an external drive

    Hello,
    my iMac (late 2009 model, OS X 10.7.4) is not booting anymore. The iMac stopps booting at the Apple logo and the spinning gear.
    I tried a couple of things that I found here in the community but nothing worked.
    start in safe mode => iMac shuts off after a couple of seconds
    start with safe boot (Shift-Command-V) => I'll get a couple of error messages, e.g. disk0s2: I/O error.   SATA WARNING: Enable Drive PHY PM failed
    reset the NVRAM/PRAM => no change
    But when I try to get access on the HD with the FireWire Target Disk Mode, I can see the following folders: Applications, Library, System, Users. But the statusbar shows 0 items for each folder and it shows that the HD has 650 GB available. I have the original 1TB HD. When I try to start OS X from an external drive I can see the same folders. I tried Data Rescue 3 to scan my files, but the software stopps with an error.
    My TimeMachine backup was not working, so I have no actual backup and need to find a solution to copy my files to an external drive.
    Instead of Data Rescue 3, I can use TechTools Pro 6 alternatively.
    Would Data Rescue 3 find files if I erase and create a new partition on the HD?
    What I found out so far, it looks like a corrupted file system.
    Have anyone an idea or a tip, how I can copy my files?
    I would be more than happy if someone can help me.
    Thank you very much for all answers in advance.

    The internal drive is failing, or has failed. You may not be able to save the data.
    There are several ways to back up a Mac that is unable to fully boot. You need an external hard drive to hold the backup data.
    1. Boot into Recovery (command-R at startup) or from a local Time Machine backup volume (option key at startup.) Launch Disk Utility and follow the instructions in the support article linked below, under “Instructions for backing up to an external hard disk via Disk Utility.”
    How to back up and restore your files
    2. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode by holding down the key combination command-T at the startup chime. Connect the two Macs with a FireWire or Thunderbolt cable. The internal drive of the machine running in target mode will mount as an external drive on the other machine. Copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    How to use and troubleshoot FireWire target disk mode
    3. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.

  • How do i copy my files from my external hard drive onto my imac

    how do i copy my files from my external hard drive onto my imac

    You should be able to 'migrate them' without having to do so during a reinstall, from an external drive. In some cases, you may be able to use TimeMachine software even if the drive had not been used as a backup.
    The usual way, though, is to drag & drop copy from one to another (volume or folder) you created in there and have open. Or drag an item on top of the icon of a hard disk drive when it is mounted on the desktop. I'm used to working with open folders and windows, because that works best; and then see if I want to change how things look inside their destination. This helps should I later want to burn them to a DVD and have it correct. And I want to know where they are.
    I had more links to some information about importing or migrating data into a Mac from an external, a week ago, but can't find them now. A few good links to pages, but I think I posted what I did find directly to answer someones question about it; and believe the info was in an Apple Support article about TimeMachine, near the lower part of the page with blue words with a disclosure triangle, so you could read more in that page. But I don't believe these two are correct in that TimeMachine (some versions) only allow wireless backup to a drive in a base station unit such as Apple sells, for this. The link I saw simply said how to work around not using the wireless stuff. Maybe it was a dated item, not in these?
    See a main general portal to TimeMachine support,
    here: http://www.apple.com/support/timemachine/
    Or basics that may not provide optional copy methods:
    Mac Basics - Time Machine backs up your mac:
    http://support.apple.com/kb/ht1427
    Perhaps a search of Apple Support database (or even ASC discussions?) would yield ideas, and perhaps find what may work for the kind of files you want to copy, and where they can be found & used later. Are the files for specific applications? Or images, music, etc?
    Good luck & happy computing!
    edited.

  • How can I copy a file through a logon script with UAC enabled ?

    Hello,
    I have a batch that is copying a file to "%public%\desktop\" (windows 7) folder through a logon GPO (GPO from user configuration).
    Everytime I try, I have an "access denied". I know it is because UAC and I don't want to disable it.
    Through explorer.exe, I can copy this file with no problem with this same account.
    How can I copy a file to such folder through group policy please ?
    I dont want to use GPP as the script is used on WinXP too and I dont have the hotfix to support GPP on this operating systems.
    Thank you

    > I have a batch that is copying a file to "%public%\desktop\" (windows 7)
    > folder through a logon GPO (GPO from user configuration).
    > Everytime I try, I have an "access denied". I know it is because UAC and
    > I don't want to disable it.
    Since you are copying to a non-user specific-directory, I'd recommend
    using a startup script instead...
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • How do I copy music files in Apple Lossless format on to a flash drive so I can play on a digital media player.

    I have an iMac 21", running on OS X Yosemite 10.10.2, processor is 2.7GHz Intel Core i%, Memory 8GB 1333MHz.
    I would like to copy some of my iTunes music in Apple Lossless or AIFF to a flash drive which I would like to insert into a digital media player in my home Hi Fi system. How do I copy the files in these formats. Thank you.

    Drag the song files there, either from the iTunes application window or the iTunes Media folder in the Finder.
    (125190)

  • How can we copy the file in to the importdp/exportdp location

    How can we copy the file in to the importdp/exportdp location after doing the import and export activity.?

    How can we copy the file in to the importdp/exportdp location after doing the import and export activity.?use Operating System command; like COPY or cp.

  • HOW do I copy jpeg files from my Windows PC to my iPad2?

    How do I copy jpeg files from my Windows PC, to my iPad2?

    If you are on iTunes 11 on your PC then you may want to enable the left-hand sidebar via View > Show Sidebar (or control-S), which might make it easier to navigate.
    To sync photos, connect and select your iPad on the left-hand sidebar of your computer's iTunes, and on the right-hand side there should be a series of tabs, one of which should be Photos - if you select that tab you can then select which photo folders to sync to the iPad's Photos app. There is a bit more info on this page. You will need to sync all the photos that you want on the iPad together in one go as only the most recent photo sync remains on the iPad - synced photos can't be deleted directly on the iPad, instead they are deleted by not including them in the next photo sync.

  • How to copy .gif files from one dir to another using runtime.exec

    hello sir/madem,
    i want to copy some gif and jepg files from one directory to another dir using swing.
    when i tried with using runtime.exec(String[]) i am getting the following error.
    anybody please tell me what is the problem in my program
    java.io.IOException: CreateProcess: ren c:/windows/desktop/copy.java c:/windows/
    cc.java error=0
    code:
    public class copy
         public static void main(String[] args)
              try{
                   String s[]=new String[3];
                        s[0]="ren";
    s[1]="c:/windows/desktop/copy.java";
    s[2]="c:/windows/cc.java";
              Runtime rt=Runtime.getRuntime();
    Process p=rt.exec(s);
              int i=p.waitFor();
              System.out.println("i is "+i);
              }catch(Exception e){System.out.println(e);}
    please mail me to [email protected]
    thanks in advance
    samba reddy
    india

    why use the Runtime? There are methods for this in the IO package ...

Maybe you are looking for

  • HP Photosmart D7260 Print Head Alignment Failure

    We had a paper jam on this printer and it took some doing to get all the pieces out.  Afterward, we could not get the printer to print black ink.  We did a printer alignment a few times and each time the alignment failed.  The black ink cartridge is

  • Alerts  based on the Message oriented

    Hi          I did Alert configuartion.. that is working fine..  what are the Error messages I'm getting in the SXMB_MONI for each  message I'm getting  an ALERT.. but for all  type of alerts here I'm getting the same message..  But    I want to catag

  • HT1766 Can I change the location of my back up formy I phone

    Hi I have not got enough on my laptop to back up my iPhone on the c drive, I would like to change the back up to save on my external drive I have but am unsure of the exact way to do it Thanks

  • Is Rotoscoping possible without Green Screen in Motion 5?

    I want to track a moving object and replace its back ground. I don't use Green Screen back ground. Is it possible in FCPX or motion 5 or at least with any plugins?

  • Will Windows 7 run Photoshop CS2?

    Will a new laptop running Windows 7 be able to run Photoshop CS2? Mary Lou