Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

I'm missing something obvious....

  • 10-07-2013 2:39pm
    #1
    Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭


    I have a shell script. As part of it, it does an scp of the command line arguments to a remote server.

    script.sh file\ 1.txt file\ 2.txt

    My problem is this - when I invoke the script I try to do scp $* <destination> within the script. With spaces it borks and scp treats each word as an argument (e.g. "file" and "1.txt"). Escaping does not work. Quotes do not work (single or double).

    I could do for i in blah, but the key for the destination has a password associated with it that I do not want to / cannot remove and I don't want to enter it each time / only want to be authenticated once.

    I'm clearly missing something trivial. What is it?


Comments

  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    Khannie wrote: »
    I have a shell script. As part of it, it does an scp of the command line arguments to a remote server.

    script.sh file\ 1.txt file\ 2.txt

    My problem is this - when I invoke the script I try to do scp $* <destination> within the script. With spaces it borks and scp treats each word as an argument (e.g. "file" and "1.txt"). Escaping does not work. Quotes do not work (single or double).

    I could do for i in blah, but the key for the destination has a password associated with it that I do not want to / cannot remove and I don't want to enter it each time / only want to be authenticated once.

    I'm clearly missing something trivial. What is it?

    What's the scp command in the sh file?
    Why not setup your ssh agent to store the passphrase, just the once?

    EDIT: Rubbish removed!


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    scp $* <destination>


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    azzeretti wrote: »
    Why not setup your ssh agent to store the passphrase, just the once?

    I want to understand what the problem is. I'll almost certainly face it again at some point. (and I feel like I may have in the past :confused:)


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    Opps, I edited while you were posting!! See above ^^


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    I am with you now. You need to pass the files in quotes then use the scp line below:
    scp $@ <destination> #NOT $*
    
    mw@YouBun2:~/perl$ ./scp.sh "two file.pl" "three file.pl" 
    sending two file.pl three file.pl
    
    count 2
    
    me@172.16.0.229's password: 
    two file.pl                                                                                                          100%   38     0.0KB/s   00:00    
    three file.pl                                                                                                        100% 1311     1.3KB/s   00:00    
    mw@YouBun2:~/perl$
    

    And this is the actual script:
    #!/bin/sh
    
    echo "sending $*\n"
    echo "count $#\n";
    
    scp "$@" me@172.16.0.229:/tmp
    
    

    Too much Turbo Cider!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,238 ✭✭✭humbert




  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    I think that should solve it. Can't currently access the box, but I will verify and get back to you. Thanks.


Advertisement