Home » Infrastructure » Linux » Batch file is not getting executed (11g, 11.2.0.1, red-hat5, linux)
Batch file is not getting executed [message #592749] Mon, 12 August 2013 01:45 Go to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear All,

In my script, i have mentioned oracle_home, oracle_sid etc. Below are the commands -
echo .
echo                  +-----------------------------------------+
echo   		      Database Refresh Utility   
echo 	         +-----------------------------------------+
echo .
echo .
echo .
echo .
echo .
export ORACLE_HOME=usr/oracle/app/oracle/product/11.2.0/dbhome_1;
export ORACLE_SID=TAGITEST; 
export PATH=/usr/sbin:$PATH; 
echo "Enter the database name :"
read dbnm


While running the batch file, getting the below error.


oracle:/usr/backup>sh impdp_TAGIC_general_39.152.sh
.
+-----------------------------------------+
Database Refresh Utility
+-----------------------------------------+
.
.
.
.
.
: command not found_39.152.sh: line 10:
: command not found_39.152.sh: line 11:
: command not found_39.152.sh: line 12:
Enter the database name :



same thing when i check it separately, it's doesn't show any problem.

oracle:/usr/backup>
oracle:/usr/backup>export ORACLE_HOME = usr/oracle/app/oracle/product/11.2.0/dbhome_1;
-bash: export: `=': not a valid identifier
-bash: export: `usr/oracle/app/oracle/product/11.2.0/dbhome_1': not a valid identifier
oracle:/usr/backup>export ORACLE_HOME=usr/oracle/app/oracle/product/11.2.0/dbhome_1;
oracle:/usr/backup>export ORACLE_SID=TAGITEST;
oracle:/usr/backup>export PATH=/usr/sbin:$PATH;
oracle:/usr/backup>


As i don't know much about the shell scripting. So, unable to rectify the problem. Kindly assist me to solve the problem.

Regards,
Ishika
Re: Batch file is not getting executed [message #592750 is a reply to message #592749] Mon, 12 August 2013 02:11 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2544
Registered: May 2013
Location: World Wide on the Web
Senior Member
Did you keep the following in the first line -

#!/bin/bash
Re: Batch file is not getting executed [message #592751 is a reply to message #592749] Mon, 12 August 2013 02:13 Go to previous messageGo to next message
Michel Cadot
Messages: 59994
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
PATH must contain $ORACLE/bin
In addition, if you use the old shell (sh), you must first set the variable then export it you can't do it on the same command:
ORACLE_HOME=usr/oracle/app/oracle/product/11.2.0/dbhome_1;export ORACLE_HOME


Regards
Michel
Re: Batch file is not getting executed [message #592753 is a reply to message #592751] Mon, 12 August 2013 02:25 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear Lalit Kumar B,

No. I have not user #!/bin/bash.

Here i got one clue. When I created new sh file in linux, with export of ORACLE_HOME & ORACLE_SID, it's worked.
But, when i extract it to windows server and done changes and placed again to linux, it's give same error.

let me work on it and share my observation.
Your suggestion is also welcome.
Thanks for sharing your valuable opinion to me

Regards,
Ishika
Re: Batch file is not getting executed [message #592762 is a reply to message #592749] Mon, 12 August 2013 03:16 Go to previous messageGo to next message
John Watson
Messages: 4860
Registered: January 2010
Location: Global Village
Senior Member
First, you are setting your ORACLE_HOME as a relative path, because you have not prefixed it with a slash. Second, you have not included $ORACLE_HOME/bin in your search path.
Re: Batch file is not getting executed [message #592765 is a reply to message #592753] Mon, 12 August 2013 03:30 Go to previous messageGo to next message
Michel Cadot
Messages: 59994
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
But, when i extract it to windows server and done changes and placed again to linux, it's give same error.


Did you transfer in TEXT mode and not BIN one?
Also

Michel Cadot wrote on Mon, 12 August 2013 09:13
PATH must contain $ORACLE/bin
In addition, if you use the old shell (sh), you must first set the variable then export it you can't do it on the same command:
ORACLE_HOME=usr/oracle/app/oracle/product/11.2.0/dbhome_1;export ORACLE_HOME


Regards
Michel

[Updated on: Mon, 12 August 2013 03:31]

Report message to a moderator

Re: Batch file is not getting executed [message #592782 is a reply to message #592753] Mon, 12 August 2013 06:16 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2544
Registered: May 2013
Location: World Wide on the Web
Senior Member
ishika_20 wrote on Mon, 12 August 2013 12:55
But, when i extract it to windows server and done changes and placed again to unix, it's give same error.


Hey, a lot of things could change when you edit in windows and place it back to unix. I have often seen CTRL-M (carriage return) characters when editing in windows.
1. Try dos2unix script.sh, to convert from windows to unix format.
2. Another way is set -x or bash -x scriptname.sh
3. Or, od -xcb testscript.sh for blank lines etc.

[EDIT : Provided link for dos2unix reference]

[Updated on: Mon, 12 August 2013 06:18]

Report message to a moderator

Re: Batch file is not getting executed [message #592796 is a reply to message #592782] Mon, 12 August 2013 07:19 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear Michel,

I have transfer it in binary mode only.

Dear Lalit Kumar B,

You are correct. When did the same thing in linux, without error its ran.

Steps- What i have done
1) created vi file
2) copied the command
3) ran it through sh shell
4) it ran without error.

Thanks to you all.

Regards,
Ishika
Re: Batch file is not getting executed [message #592798 is a reply to message #592796] Mon, 12 August 2013 07:32 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2544
Registered: May 2013
Location: World Wide on the Web
Senior Member
Glad to know your issue is fixed. With vi editor you can reveal a lot of environment specific things, like the CTRL-M (carriage return) characters etc.

Regards,
Lalit
Re: Batch file is not getting executed [message #592818 is a reply to message #592798] Mon, 12 August 2013 08:56 Go to previous message
Michel Cadot
Messages: 59994
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
... and the origin is your transfer in binary mode and not text/ascii one.

Regards
Michel
Previous Topic: export script doesn't make gzip of dmp file
Next Topic: import script doesn't call dump file & oracle_sid
Goto Forum:
  


Current Time: Sat Dec 20 03:57:07 CST 2014

Total time taken to generate the page: 0.05267 seconds