LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-03-2011, 01:06 PM   #1
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Rep: Reputation: 15
Issue with remote script execution


I have a very simple script that creates another script that I want to copy over to my oracle server (on a separate machine from my resin server) and then execute. It looks like this:
Code:
#!/bin/bash
echo "#!/bin/bash

/path/to/sqlplus -s /nolog <<EOF
connect username/password
@file1.sql
@file2.sql
@file3.sql
@file4.sql
EOF" > /home/user/trythis.sh

scp /home/user/trythis.sh oracle@11.1.11.111:/tmp/script
ssh oracle@11.1.11.111 bash /tmp/script/trythis.sh
The new script (trythis.sh) creates and copies over to the oracle server fine. I can even log into the oracle server and execute the script and it executes completely without issue. The problem is when I try to execute the script from my resin machine (either within the original script or just from the regular prompt). I type:

ssh oracle@11.1.11.111 bash /tmp/script/trythis.sh

and I get:

Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

Any ideas? I'm pretty sure ORACLE_HOME is set on my oracle machine because, as I said, I can execute the exact same script fine when logged into my oracle machine. I read something about sourcing the bash profile but I couldn't figure out the details of what was being talked about and I also didn't know if it was relevant to my issue (came up when I searched for the error I was getting).
 
Old 05-03-2011, 03:40 PM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,487

Rep: Reputation: 88
Quote:
ssh oracle@11.1.11.111 bash /tmp/script/trythis.sh

and I get:

Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
Bit of a shot in the dark, but what usergroup / user does that file (erm... probably sp1_en.msb??) belong to?

E. g. it looks like your script is starting up, but the user it is running as does not have permission to access some of the files the script (or binaries it starts up) need to be able to read to run.

I'd try finding that file with something like (as root):

Code:
find / -name sp1_en.msb
and then checking its permissions. Maybe if you can find this file you can try changing its permissions to be, for example, world readable and see if that changes anything??
 
Old 05-03-2011, 04:01 PM   #3
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rylan76 View Post
Bit of a shot in the dark, but what usergroup / user does that file (erm... probably sp1_en.msb??) belong to?

E. g. it looks like your script is starting up, but the user it is running as does not have permission to access some of the files the script (or binaries it starts up) need to be able to read to run.

I'd try finding that file with something like (as root):

Code:
find / -name sp1_en.msb
and then checking its permissions. Maybe if you can find this file you can try changing its permissions to be, for example, world readable and see if that changes anything??
Interesting...when I do what you said I get this:

Code:
-bash-3.00$ find / -name sp1_en.msb
find: /root: Permission denied
find: /home/postgres: Permission denied
find: /home/nbbs: Permission denied
find: /var/gdm: Permission denied
find: /var/cache/samba/winbindd_privileged: Permission denied
find: /var/cache/alchemist/printconf.rpm/wm: Permission denied
find: /var/cache/alchemist/printconf.local/wm: Permission denied
find: /var/cache/mod_proxy: Permission denied
find: /var/log/samba: Permission denied
find: /var/log/ppp: Permission denied
find: /var/log/httpd: Permission denied
find: /var/log/audit: Permission denied
find: /var/empty/sshd: Permission denied
find: /var/lib/php/session: Permission denied
find: /var/lib/slocate: Permission denied
find: /var/lib/pgsql: Permission denied
find: /var/lib/dav: Permission denied
find: /var/lib/nfs/statd: Permission denied
find: /var/lib/dhcpv6: Permission denied
find: /var/run/mdmpd: Permission denied
find: /var/run/mdadm: Permission denied
find: /var/run/sudo: Permission denied
find: /var/run/usb: Permission denied
find: /var/net-snmp: Permission denied
find: /var/lock/lvm: Permission denied
find: /var/spool/at: Permission denied
find: /var/spool/cups: Permission denied
find: /var/spool/clientmqueue: Permission denied
find: /var/spool/cron: Permission denied
find: /var/spool/mqueue: Permission denied
find: /usr/share/ssl/CA: Permission denied
find: /usr/local/u01/app/pgsql/data: Permission denied
find: /boot/lost+found: Permission denied
find: /etc/racoon/certs: Permission denied
find: /etc/cups/certs: Permission denied
find: /lost+found: Permission denied
find: /mnt/disk3/lost+found: Permission denied
find: /mnt/disk4/lost+found: Permission denied
find: /mnt/disk2/lost+found: Permission denied
find: /proc/tty/driver: Permission denied
find: /proc/1/task/1/fd: Permission denied
find: /proc/2/task/2/fd: Permission denied
find: /proc/3/task/3/fd: Permission denied
find: /proc/4/task/4/fd: Permission denied
find: /proc/5/task/5/fd: Permission denied
find: /proc/6/task/6/fd: Permission denied
find: /proc/7/task/7/fd: Permission denied
find: /proc/8/task/8/fd: Permission denied
find: /proc/9/task/9/fd: Permission denied
find: /proc/37/task/37/fd: Permission denied
find: /proc/38/task/38/fd: Permission denied
find: /proc/48/task/48/fd: Permission denied
find: /proc/51/task/51/fd: Permission denied
find: /proc/52/task/52/fd: Permission denied
find: /proc/39/task/39/fd: Permission denied
find: /proc/50/task/50/fd: Permission denied
find: /proc/125/task/125/fd: Permission denied
find: /proc/205/task/205/fd: Permission denied
find: /proc/206/task/206/fd: Permission denied
find: /proc/210/task/210/fd: Permission denied
find: /proc/211/task/211/fd: Permission denied
find: /proc/231/task/231/fd: Permission denied
find: /proc/678/task/678/fd: Permission denied
find: /proc/1180/task/1180/fd: Permission denied
find: /proc/1801/task/1801/fd: Permission denied
find: /proc/1802/task/1802/fd: Permission denied
find: /proc/1822/task/1822/fd: Permission denied
find: /proc/1823/task/1823/fd: Permission denied
find: /proc/1824/task/1824/fd: Permission denied
find: /proc/1825/task/1825/fd: Permission denied
find: /proc/2361/task/2361/fd: Permission denied
find: /proc/2365/task/2365/fd: Permission denied
find: /proc/2376/task/2376/fd: Permission denied
find: /proc/2388/task/2388/fd: Permission denied
find: /proc/2409/task/2409/fd: Permission denied
find: /proc/2439/task/2439/fd: Permission denied
find: /proc/2530/task/2530/fd: Permission denied
find: /proc/2585/task/2585/fd: Permission denied
find: /proc/2600/task/2600/fd: Permission denied
find: /proc/2616/task/2616/fd: Permission denied
find: /proc/2659/task/2659/fd: Permission denied
find: /proc/2661/task/2661/fd: Permission denied
find: /proc/2663/task/2663/fd: Permission denied
find: /proc/2664/task/2664/fd: Permission denied
find: /proc/2686/task/2686/fd: Permission denied
find: /proc/2694/task/2694/fd: Permission denied
find: /proc/2705/task/2705/fd: Permission denied
find: /proc/2715/task/2715/fd: Permission denied
find: /proc/2738/task/2738/fd: Permission denied
find: /proc/2757/task/2757/fd: Permission denied
find: /proc/2776/task/2776/fd: Permission denied
find: /proc/2786/task/2786/fd: Permission denied
find: /proc/2797/task/2797/fd: Permission denied
find: /proc/2807/task/2807/fd: Permission denied
find: /proc/2808/task/2808/fd: Permission denied
find: /proc/2809/task/2809/fd: Permission denied
find: /proc/2812/task/2812/fd: Permission denied
find: /proc/2817/task/2817/fd: Permission denied
find: /proc/2820/task/2820/fd: Permission denied
find: /proc/2836/task/2836/fd: Permission denied
find: /proc/3086/task/3086/fd: Permission denied
find: /proc/3091/task/3091/fd: Permission denied
find: /proc/3520/task/3520/fd: Permission denied
find: /proc/5314/task/5314/fd: Permission denied
find: /proc/23168/task/23168/fd: Permission denied
find: /proc/11201/task/11201/fd: Permission denied
find: /proc/11203/task/11203/fd: Permission denied
-bash-3.00$
So how to I even start with finding which file I need to change the permissions of? Also, when I just run the script from the oracle machine (instead of remotely) I am logged in as user 'oracle' and it runs fine. So does it make sense that I would have permission problems when I ssh into the machine as the same user 'oracle'? I'm stumped.
 
Old 05-03-2011, 07:12 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
1. you prob don't need to change perms on the msb file, but fyi, when running find across the whole system, re-direct errors to null eg

Code:
find / -name sp1_en.msb 2>/dev/null
2. you can src the ORACLE env setup in you script, you just have to know where it's set eg
Code:
#!/bin/bash
echo "#!/bin/bash   # why are you doing this ???

. /home/oracle/.bashrc

/path/to/sqlplus -s /nolog <<EOF
.
.
.
 
Old 05-03-2011, 11:36 PM   #5
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
Code:
#!/bin/bash
echo "#!/bin/bash   # why are you doing this ???
I'm doing that because my main script is creating another script that's copied over to the Oracle machine. The beginning of the script being created is "#!/bin/bash" just like the beginning of my main script. Is this not correct?

As far as the ORACLE env variable thing goes... I'm a little confused. The ORACLE_HOME variable IS set on the oracle machine and as I said, the script that's copied over executes fine on the oracle machine. That being said, I did source the ORACLE environment as you suggested and I still get the same error.

The other way I tried first was just running each sql command individually via ssh within the main script, example:

Code:
ssh oracle@11.1.11.111 path/to/sqlplus user/pass @/path/to/sql/script/on/oracle/machine.sql
ssh oracle@11.1.11.111 path/to/sqlplus user/pass @/path/to/another/script.sql
.
.
.
...that effort resulted in the same error:

Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

I think I've ruled out the ORACLE_HOME set issue but I'm open to suggestions.

Any other reason you guys can think of that the script would execute fine on the oracle box but not via ssh from my resin box? OR, any suggestions as to how I can do something similar in another way?
 
Old 05-05-2011, 04:03 PM   #6
Orange Sunshine
Member
 
Registered: Jul 2004
Location: Kansas
Posts: 37

Original Poster
Rep: Reputation: 15
Well, I've been at this issue for 2 solid days now and am not getting anywhere. Does anyone know what the issue could be or have a better way for me to execute the sqlplus scripts from my resin machine (where no oracle instance is installed)?
 
Old 05-09-2011, 05:48 AM   #7
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,487

Rep: Reputation: 88
[QUOTE=Orange Sunshine;4345414]Interesting...when I do what you said I get this:

Code:
-bash-3.00$ find / -name sp1_en.msb
find: /root: Permission denied
find: /home/postgres: Permission denied
find: /home/nbbs: Permission denied
<snip>
-bash-3.00$
My bad. You need to become root before you do that find / -name sp1_en.msb command...

Quote:
So how to I even start with finding which file I need to change the permissions of? Also, when I just run the script from the oracle machine (instead of remotely) I am logged in as user 'oracle' and it runs fine. So does it make sense that I would have permission problems when I ssh into the machine as the same user 'oracle'? I'm stumped.
You might. I once had this same situation with an old SCO / Unix system I had to get into. On the machine itself, no problem logging in directly as a bash user and doing things. However, if I came in over SSH (or even telnet) it somehow "knew" I wasn't on that machine - I could still get in as the user I used physically on it, but my permissions where restricted. Not sure (to this day - it was years ago) just how it detected that...
 
Old 05-09-2011, 05:54 AM   #8
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,487

Rep: Reputation: 88
Quote:
Originally Posted by Orange Sunshine View Post
Any other reason you guys can think of that the script would execute fine on the oracle box but not via ssh from my resin box? OR, any suggestions as to how I can do something similar in another way?
Well, not sure if it will work for your situation and requirements, but how about starting the script locally, not remotely?

E. g. you still go ahead and copy your script over as required. However, you do NOT start it from your remote connection. How about setting up a script on the target machine, that is run by cron locally on that machine, that starts your script?

E. g. setup a cron that runs each five minutes. All it does is call your script that has been copied in whenever like you detail in your above messages. This way, from everything on the target machine's viewpoint, the script starts up LOCALLY, via cron, so it should have all the permissions it needs? Just write the cron script locally "as" the user which runs Oracle.

You can then add refinements such as having the cronned script just die quietly if your "command script" is not present in a certain folder. This way you can precisely control when and what is executed, simply by copying over the script, leaving for at least 6 minutes (thus ensuring execution somewhere in that time window, by cron, of the script) and then deleting it remotely?

You can do all this quite easily with PHP for example, as regards making an FTP connection to copy the file to a certain location, then deleting it after a time delay... you can even farm that time delay functionality out to the cron on your remote system?

The idea of course being to NOT try to run the script remotely, but having it run locally as the correct user Oracle runs as anyway. This should short-circuit any permission complaints, I hope...

Last edited by rylan76; 05-09-2011 at 05:56 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a shall script for remote shell execution ramesh14 Linux - Newbie 3 03-27-2011 08:59 AM
issue with execution of PERL script rotkmaninov Linux - Software 6 07-10-2008 03:47 PM
Remote Script execution from the central location anil_garg5 Linux - General 5 05-11-2006 04:29 PM
script execution - file/directory permission issue serksimper Linux - Enterprise 1 08-10-2005 04:01 PM
Remote Execution issinho Linux - Networking 5 07-08-2005 02:11 PM


All times are GMT -5. The time now is 05:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration