LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-12-2019, 11:34 PM   #1
jyothinagendra
LQ Newbie
 
Registered: May 2019
Posts: 3

Rep: Reputation: Disabled
Error While executing the shell script


While I am executing the below line in the shell script I am getting this error,


cd /home/users/test/scripts/ && . test ORACLE18C

/home/users/test/scripts/Rman_Backup_Archi.sh: line 9: .: test: file not found
 
Old 06-13-2019, 12:35 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,640

Rep: Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481Reputation: 2481
Post the script in CODE blocks https://www.linuxquestions.org/quest...do=bbcode#code
 
1 members found this post helpful.
Old 06-13-2019, 12:41 AM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,066

Rep: Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069
Quote:
Originally Posted by jyothinagendra View Post
While I am executing the below line in the shell script I am getting this error,

Code:
cd /home/users/test/scripts/ && . test ORACLE18C

/home/users/test/scripts/Rman_Backup_Archi.sh: line 9: .: test: file not found
dot space test says "source the file named test in the directory you're in" Not sure what happens with the ORACLE18C string...

Is there a file named test in /home/users/test/scripts/ ? (apparently not)
 
1 members found this post helpful.
Old 06-13-2019, 06:41 AM   #4
jyothinagendra
LQ Newbie
 
Registered: May 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
dot space test says "source the file named test in the directory you're in" Not sure what happens with the ORACLE18C string...

Is there a file named test in /home/users/test/scripts/ ? (apparently not)
Here test is a shell script designed for setting environment variables like bash script .
 
Old 06-13-2019, 07:06 AM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,066

Rep: Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069
Quote:
Originally Posted by jyothinagendra View Post
Here test is a shell script designed for setting environment variables like bash script .
And there’s an error in it? See #2, please.
 
1 members found this post helpful.
Old 06-13-2019, 07:27 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,696
Blog Entries: 13

Rep: Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202
Quote:
Originally Posted by jyothinagendra View Post
cd /home/users/test/scripts/ && . test ORACLE18C

/home/users/test/scripts/Rman_Backup_Archi.sh: line 9: .: test: file not found
Quote:
Originally Posted by jyothinagendra View Post
Here test is a shell script designed for setting environment variables like bash script .
Based on the error, the file test is not in the directory /home/users/scripts.

There are a couple of other issues. Such as whether or not test is a shell script file, it will need to be. It will need to be executable, and it will need a shebang term at the start of it. My parser will not accept a file with an improper extension, using that form of shell execution. Meanwhile if I use the more normal shell notation to run something, it will accept a file with no extension. That file does need to be a proper shell script file.

So, you need to post more details about things here. As others have said, use code tags because they preserve the spacing and formatting of the code. If you need assistance with that, there are guides in the LQ Site FAQ, or just use the advanced editor when you post and the # tool will make selected text into a code block.

Advice here is that providing brief, one line, not-detailed follow-ups are no further help to people. If you wish to maintain privacy of your code, then post representative examples of it.
 
1 members found this post helpful.
Old 06-13-2019, 08:01 AM   #7
ehartman
Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 581

Rep: Reputation: 274Reputation: 274Reputation: 274
Quote:
Originally Posted by rtmistler View Post
It will need to be executable, and it will need a shebang term at the start of it.
Sorry to contradict you, but neither is true for a "sourced" script. As it will be executed BY the current shell anyway, a "shebang" will be ignored.
It doesn't need to have executable rights either, the shell will run it in either case.
 
Old 06-13-2019, 08:32 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,696
Blog Entries: 13

Rep: Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202
Quote:
Originally Posted by ehartman View Post
Sorry to contradict you, but neither is true for a "sourced" script. As it will be executed BY the current shell anyway, a "shebang" will be ignored.
It doesn't need to have executable rights either, the shell will run it in either case.
Yes, probably, and won't argue your points. I've got bash, but it may not be a current bash. Mine shows 4.4 built back in 2016 and happens to presently be running via cygwin.

I played a bit on my shell and given the notation of DOT SPACE <script>, I could only source something which allowed execute permissions. I turned it on and off and found what I found. Meanwhile it also would not accept anything without a .sh extension.

Now if I used DOT SLASH <script> things worked far better. I still needed it to have execute permissions.

I would agree with you that the intentions of the shell should allow any file which contains shell commands to be sourced, but on my install, I only found what I found. All empirical, and not something I'm invested in disagreement about. There are those who have far more expertise with the shell than I.
 
Old 06-13-2019, 08:47 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,207

Rep: Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910
Quote:
Originally Posted by rtmistler View Post
It will need to be executable, and it will need a shebang term at the start of it. My parser will not accept a file with an improper extension, using that form of shell execution.
What parser is that? For bash, neither executable permission nor the shebang is needed.
 
Old 06-13-2019, 08:57 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,696
Blog Entries: 13

Rep: Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202
Quote:
Originally Posted by rknichols View Post
What parser is that? For bash, neither executable permission nor the shebang is needed.
Sorry, not parser, shell.

Says it's bash 4.4 circa 2016, but presently running in cygwin.

I just goes by what I typed, what worked, and didn't.
 
Old 06-13-2019, 09:19 AM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,207

Rep: Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910
Quote:
Originally Posted by rtmistler View Post
Says it's bash 4.4 circa 2016, but presently running in cygwin.

I just goes by what I typed, what worked, and didn't.
As do I.

bash 4.3.30(1) in Debian 8
bash 4.1.2(2) in CentOS 6
bash 4.4.23(1) in Fedora 29

None of those require either execute permission or a shebang line in a file being sourced.
 
Old 06-13-2019, 04:34 PM   #12
ehartman
Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 581

Rep: Reputation: 274Reputation: 274Reputation: 274
Quote:
Originally Posted by rknichols View Post
bash 4.3.30(1) in Debian 8
bash 4.1.2(2) in CentOS 6
bash 4.4.23(1) in Fedora 29

None of those require either execute permission or a shebang line in a file being sourced.
Neither did bash 4.2.053 on Slackware (I tested it before I posted my previous response, just forgot to say so).
 
Old 06-14-2019, 11:34 AM   #13
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 348

Rep: Reputation: 156Reputation: 156
Source will not look in the current directory for its file if the script is in POSIX mode.

https://www.gnu.org/software/bash/ma...OSIX-Mode.html
Quote:
When invoked as sh, Bash enters POSIX mode after reading the startup files.
The following list is what’s changed when ‘POSIX mode’ is in effect:
<snip>
42. The . and source builtins do not search the current directory for the filename argument if it is not found by searching PATH.
 
3 members found this post helpful.
  


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
Crontab not executing my shell script its executing standlaone atulkvtiwari Linux - Newbie 15 12-04-2018 06:25 AM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
command not found error while executing a shell script SurbhiJain Linux - Newbie 15 07-26-2010 09:18 AM
Sntax error : unexpected end of file while executing shell script priyankarathi Linux - Newbie 5 04-21-2009 01:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 PM.

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