0

I'm trying to get a value from another shell script and assigning it to a variable in a shell script

I tried with the below command. But it's not working

BundleVersion= $(sh VersionNumberScript $(PLISTPATH))

Can I know what's wrong in the above command

2
  • Probably you want $(PLISTPATH) to be $PLISTPATH, in addition to the note about the space after the equal sign, which should not be there. Commented Feb 17, 2017 at 8:26
  • Indeed, I didn't notice this. Well, unless PLISTPATH is a command, but it doesn't seem to be. Commented Feb 17, 2017 at 18:46

1 Answer 1

1

You have an extra space after =, which shouldn't be there. The syntax for assignment in shell is:

variable=value

If you write

variable= value

it will be interpreted as

variable='' value

which stands for "execute command 'value' after setting environment variable 'variable' to the empty string".

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

2 Comments

I have tried this but its not working. When I'm trying to run the script its printing, but its not getting assigned to a variable
@Icoder: It's hard to diagnose, when you don't even mention in which shell you are executing this command. The following applies, if it's in bash: First, a program named PLISTPATH is executed (in a child process), and its standard output is collected. Then, the program VersionNumberScript is executed (either as Posix-Shell or as Bourne Shell, depending on where you are on), and receives the previously collected output as parameter(s). Finally, the output of VersionNumberScript is stored in the variable BundleVersion.

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.