0

I have an application in Unix. I use the below command to connect to it: ./application -a "connect"

I want to do the same through the shell script, for which i assigned the command line to a variable like:

newcommand = './application -a "connect"'
$newcommand

But this is not working.

However the first part of the code is working. i.e.,:

newcommand = "./application"

$newcommand

Can anyone point out what i am missing.

  • What does your script look like and what error message are you getting? – Peter Sep 03 '18 at 14:56
  • Yeah. @Geouse Feroz, it would be handy to know exactly what you run, exactly what happens and exactly what you expected to happen. – ctt Sep 03 '18 at 15:17

1 Answers1

1

Believe it or not, this:

newcommand = "./application"

...has the shell run the command, newcommand with the arguments, =, and ./application.

In shell simple assignments cannot have any unprotected whitespace or they'll be interpreted as a command.

Consider:

newcommand=./application
$newcommand

...notice that there's no space around the = sign in the assignment.

ctt
  • 1,405
  • 8
  • 18