0

To set environment variable, i am doing source in (by using the below command) whenever i start to work in my Linux Working environment . /opt/kmc/pbs/env/1.1/etc/setup.env rev.52

When add the this line(". /opt/kmc/pbs/env/1.1/etc/setup.env rev.52") in to my shell script

Its not running, it returns some error. I created alias also. even though not able to execute this.

alias test='. /opt/kmc/pbs/env/1.1/etc/setup.env rev.52'
test

So how can i do "source in" with in script instead of giving this command manually

2
  • If you put double quotes around it as shown in your example that will give you a syntax error. Remove the double quotes. Commented Mar 21, 2013 at 9:49
  • For highliting purpose, i am don double quotes.... Commented Mar 21, 2013 at 10:10

2 Answers 2

1

That's strange. In BASH you can do both:

. /path/to/your/skript

or

source /path/to/your/skript

What ist your path to the script you want to source? Is it '/opt/fedex/pbs/env/1.1/etc/setup.env rev.52'

then you should do this:

   . '/opt/fedex/pbs/env/1.1/etc/setup.env rev.52' 

or

  source '/opt/fedex/pbs/env/1.1/etc/setup.env rev.52'
Sign up to request clarification or add additional context in comments.

6 Comments

source '/opt/kmc/pbs/env/1.1/etc/setup.env rev.52' or . '/opt/kmc/pbs/env/1.1/etc/setup.env rev.52' $ sh s5.sh s5.sh: line 1: /opt/kmc/pbs/env/1.1/etc/setup.env rev.52: No such file or directory
Is your path actually '/opt/kmc/pbs/env/1.1/etc/setup.env rev.52'? This is something only you can really verfy.
$ source /opt/kmc/pbs/env/1.1/etc/setup.env rev.52 Environment phase (default=prod): devel User build project: rev User build release: 52.0 User build label: devel User OrgName: srs User OrgName release: 52.0 User AppName: rev User AppName release: 52.0 Reading rev.env ... done.
Are you sourcing two files? One with an absolute path '/opt/fedex/pbs/env/1.1/etc/setup.env' and one with a relative path 'rev.52'?
The above command working fine. But when i add the same line in my shell script, its return error
|
1

You can use the source command. That is:

source /path/to/file

And note, if you mention "some error", we can't help much with that. Unless you are specifying what kind of errors were those.

1 Comment

But when i do using script, go the below error............$ sh s5.sh /opt/kmc/pbs/env/1.1/etc/setup.env: line 125: print: command not found Environment phase (default=prod): /opt/kmc/pbs/env/1.1/etc/setup.env: line 70: print: command not found

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.