0

I'm totally new in Bash programming, so please don't feel offended with my question. I'm trying to use SCP command with parameters from configuration file. Now my code looks like below

#!/usr/bin/bash

source $1

echo $HOST
echo $USER
echo $DIRECTORY

scp ${USER}@${HOST}:/${DIRECTORY}/file.zip .

And my output is:

111.111.11.111
user1
/home/repo/test/
: Name or service not knowname 111.111.11.111

If I will remove ${HOST} from command and I'll paste address directly, it's working perfectly. Other variables are passed without problem. Do you have any idea where I'm doing it wrong? I am completely lost. I'm running this script from Cygwin terminal, but I think it's not a problem.

5
  • Have you tried with following syntax? scp ${USER}@$HOST:/${DIRECTORY}/file.zip . Commented Mar 23, 2017 at 8:46
  • Yes, and it's the same Commented Mar 23, 2017 at 8:47
  • Just tried by removing all the '{' and '}' and it works fine in my system, that is: scp $USER@$HOST:/$DIRECTORY/file.zip . Commented Mar 23, 2017 at 8:48
  • 1
    Can it be that some of the strings contain some nonprintable characters (\r or so?). Commented Mar 23, 2017 at 9:42
  • You are right! I changed EOL conversion for config file to UNIX and it's working! Thanks a lot Commented Mar 23, 2017 at 10:04

1 Answer 1

1

According to Jakuje comment, the problem was in config file. I've changed EOL conversion to UNIX and it's working perfectly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.