Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Using xargs to scp line-delimited arguments?


    Hi

    I use mercurial (hg) for version control. The hg status -n command will return a line-delimited list of file names that are out of synch with the repository.

    I am trying to write a bash script that will secure copy the output of hg status -n.

    Thus far I have:
    Code:
    hg st -n | xargs scp mysite.com
    But the result is:
    Code:
    test2.txt: Not a directory
    where test2.txt is the 2nd line of 2 lines of output from the hg command.

    I guess I'm really wanting to know how to get my arguments squeezed between the "scp" and the "mysite.com:public_html". But I have no idea how!

    Any help would be great!
    Thanks :)

  2. #2
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,375
    Hi.

    I'm not clear if you wish to copy the list of names or the files themselves to a remote host with scp. It's always best to show the results that you desire. If you wish to copy the names, you can place them in a local file and use scp to copy that single file.

    For copying the files themselves 1) Use "-n 1" and "-I" (uppercase "i") xargs options, or 2) create a script to pass xargs arguments to it, re-arrange as desired -- in either case to get something like a series of:
    Code:
    scp file user@host:file
    Best wishes ... cheers, drl
    Last edited by drl; 05-19-2013 at 12:14 PM.
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •