# Basic Shell Scripting

**URL:** <https://community.unix.com/t/basic-shell-scripting/346436>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [September 18, 2014, 11:18am UTC](https://community.unix.com/t/basic-shell-scripting/346436 "2014-09-18T11:18:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkat8439](https://community.unix.com/letter_avatar/venkat8439/32/6_449c533f586939b6e5f246632a46421f.png) [@venkat8439](https://community.unix.com/u/venkat8439)\
**Post date:** [September 18, 2014, 11:18am UTC](https://community.unix.com/t/basic-shell-scripting/346436/1 "2014-09-18T11:18:03Z")

</div>

Hi All,

I am a newbie to shell scripting. I am trying to something like this.

```nohighlight
#!bin/bash
cd /u01/app/oracle/

# then start the process
./opmnctl startall

```

Can someone help me with this requirement.

Help is very much appreciated.

Thanks  
Venkat

---

<div class="post-metadata">

**Author:** ![Makarand\_Dodmis](https://community.unix.com/letter_avatar/makarand_dodmis/32/6_449c533f586939b6e5f246632a46421f.png) [@Makarand\_Dodmis](https://community.unix.com/u/Makarand_Dodmis)\
**Post date:** [September 18, 2014, 11:20am UTC](https://community.unix.com/t/basic-shell-scripting/346436/2 "2014-09-18T11:20:47Z")

</div>

try

```nohighlight
#!bin/bash

# start the process from absolute path
. /u01/app/oracle/opmnctl startall

```

---

<div class="post-metadata">

**Author:** ![Scrutinizer](https://community.unix.com/user_avatar/community.unix.com/scrutinizer/32/1216_2.png) [@Scrutinizer](https://community.unix.com/u/Scrutinizer)\
**Post date:** [September 18, 2014, 11:25am UTC](https://community.unix.com/t/basic-shell-scripting/346436/3 "2014-09-18T11:25:25Z")

</div>

The shebang needs an absolute file path:

```nohighlight
#!/bin/bash

```

Does `/u01/app/oracle/opmnctl` exist? What does

```nohighlight
ls -l /u01/app/oracle/opmnctl

```

produce?

--  
@makarand Dodmis: that would be sourcing

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/6_449c533f586939b6e5f246632a46421f.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [September 18, 2014, 11:26am UTC](https://community.unix.com/t/basic-shell-scripting/346436/4 "2014-09-18T11:26:08Z")

</div>

Hello venkat8439,

Welcome to the forum. It's a request please use the code tage while posting the codes and commands as per forum rules. Now for your script yes you are going good. You need to put the same commands in a file which should have execution permission(or depending on your need like if you allow others to execute or not) and then try to execute it. Also keep shebang on top of the script.

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![venkat8439](https://community.unix.com/letter_avatar/venkat8439/32/6_449c533f586939b6e5f246632a46421f.png) [@venkat8439](https://community.unix.com/u/venkat8439)\
**Post date:** [September 18, 2014, 11:41am UTC](https://community.unix.com/t/basic-shell-scripting/346436/5 "2014-09-18T11:41:01Z")

</div>

Hi All,

```nohighlight
#!/bin/bash
. /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl status

```

I am getting this output

```nohighlight
[oracle@xxxxxx obiee_scripts]$ ./start_opmnctl1.sh
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 25: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 26: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: syntax error near unexpected token `('

```

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [September 18, 2014, 11:54am UTC](https://community.unix.com/t/basic-shell-scripting/346436/6 "2014-09-18T11:54:35Z")

</div>

Update your PATH variable at the beginning of your script by adding ` /u01/app/oracle/obiee117g/instances/instance1/bin ` to it and try again...  
e.g.

```nohighlight
export PATH=$PATH:$HOME/bin:/u01/app/oracle/obiee117g/instances/instance1/bin

```

---

<div class="post-metadata">

**Author:** ![venkat8439](https://community.unix.com/letter_avatar/venkat8439/32/6_449c533f586939b6e5f246632a46421f.png) [@venkat8439](https://community.unix.com/u/venkat8439)\
**Post date:** [September 18, 2014, 12:02pm UTC](https://community.unix.com/t/basic-shell-scripting/346436/7 "2014-09-18T12:02:13Z")

</div>

```nohighlight
#!/bin/bash
export PATH=$PATH:/u01/app/oracle/obiee117g/instances/instance1/bin
. /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl status

```

Is this right ??

If so.. I am getting following message

```nohighlight
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 25: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 26: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: syntax error near unexpected token `('
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: `%commands = ('

```

Thanks  
Venkat

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [September 18, 2014, 12:08pm UTC](https://community.unix.com/t/basic-shell-scripting/346436/8 "2014-09-18T12:08:57Z")

</div>

As scrutinizer mentionned in post#3 `. ~something ` is sourcing which means you changed an environment that will affect all your current shell.. Doing that with a program would mean " Replace my (current) shell by program" and at the end of program it exits and you are doomed since you have no shell anymore...

---

<div class="post-metadata">

**Author:** ![venkat8439](https://community.unix.com/letter_avatar/venkat8439/32/6_449c533f586939b6e5f246632a46421f.png) [@venkat8439](https://community.unix.com/u/venkat8439)\
**Post date:** [September 18, 2014, 12:10pm UTC](https://community.unix.com/t/basic-shell-scripting/346436/9 "2014-09-18T12:10:01Z")

</div>

> [@vbe](#):
>
> Update your PATH variable at the beginning of your script by adding ` /u01/app/oracle/obiee117g/instances/instance1/bin ` to it and try again...  
> e.g.
> 
> ```plaintext
> export PATH=$PATH:$HOME/bin:/u01/app/oracle/obiee117g/instances/instance1/bin
> 
> ```

Hi,

I tried

```plaintext
[oracle@xxxxx obiee_scripts]$ ./start_opmnctl1.sh 
./start_opmnctl1.sh: line 2: iexport: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 25: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 26: =: command not found
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: syntax error near unexpected token `('
/u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: `%commands =

```

I am using OEL6

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [September 18, 2014, 12:16pm UTC](https://community.unix.com/t/basic-shell-scripting/346436/10 "2014-09-18T12:16:19Z")

</div>

I cant answer for you, since it doesnt look as a standard installation...  
Usually you would have all you need in ` $ORACLE_HOME/opmn/bin/ `

---

<div class="post-metadata">

**Author:** ![Scrutinizer](https://community.unix.com/user_avatar/community.unix.com/scrutinizer/32/1216_2.png) [@Scrutinizer](https://community.unix.com/u/Scrutinizer)\
**Post date:** [September 18, 2014, 12:18pm UTC](https://community.unix.com/t/basic-shell-scripting/346436/11 "2014-09-18T12:18:00Z")

</div>

The suggestion in post #2 is wrong. Following vbe's path approach, you could try:

```nohighlight
#!/bin/bash
export PATH=$PATH:/u01/app/oracle/obiee117g/instances/instance1/bin
opmnctl status

```
