Unable to source file in my script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to source file in my script
# 1  
Old 11-30-2016
Bug Unable to source file in my script

Hi,

Code:
ls -ltrq res.file
-rwxrwxr-x   1 ora   install    4278 Nov 30 07:19 res.file
$ more test.sh
source res.file
$ ./test.sh
./test.sh[1]: .: res.file: cannot open [No such file or directory]
$ id
uid=600000014(ora) gid=63855(install)
uname -a
SunOS mymac 5.11 11.2 sun4v sparc sun4v

The same thing works fine on a Linux box.

Can you tell me why i m getting No such file or directory error when the file is in the same directory?
# 2  
Old 11-30-2016
Without deeper analysis - check for DOS <CR> (\r, ^M, 0x0D) line terminators.
# 3  
Old 11-30-2016
Check the PATH environment variable.
# 4  
Old 11-30-2016
Bug

Quote:
Originally Posted by RudiC
Without deeper analysis - check for DOS <CR> (\r, ^M, 0x0D) line terminators.
I don't see any special characters in the file.

Code:
echo $PATH
/usr/bin:/usr/sbin
$ cat -ev res.file
#By Myself$
$
# Environment Variables$
TIMESTAMP=`date "+%Y%h%d_at_TIME_%H_%M_%S"`$

Can you please suggest ?

Last edited by mohtashims; 11-30-2016 at 10:22 AM..
# 5  
Old 11-30-2016
Either change the PATH to:
Code:
PATH=/usr/bin:/usr/sbin:.

or
change the script to:
Code:
source ./res.file

This User Gave Thanks to jgt For This Post:
# 6  
Old 11-30-2016
Quote:
Originally Posted by mohtashims
I don't see any special characters in the file.
Code:
echo $PATH
/usr/bin:/usr/sbin
$ cat -ev response.file
#By Myself$
$
# Environment Variables$
TIMESTAMP=`date "+%Y%h%d_at_TIME_%H_%M_%S"`$

Can you please suggest ?
Hello mohtashims,

Just a small thing here, did you try to get it in a new session, try to login to the server by a new session and have a try then.

EDIT: By seeing your error closely it may be an issue with complete path for source res.file, so is it the case like your script is in a different path and then you have to provide complete path for it, could you please give it a try and let us know then how it goes.

Thanks,
R. Singh

Last edited by RavinderSingh13; 11-30-2016 at 10:17 AM.. Reason: Added one more suggestion successfully too.
# 7  
Old 11-30-2016
Even though i did not see any special M ^M characters using the cat -ev res.file i did dos2unix res.file res.file and that seems to have resolved the error.

But, any explanation please ??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script Comment code blocks in a bash source file

Just began to learn on Shell Script. I got an exercise from my friend. I know how to make this happen in C, but I'm not familiar with Shell Script. Hope I can get some help from all of you. I want to write a bash script to comment code blocks in a bash source file. What I mean comment is '#', I... (1 Reply)
Discussion started by: HiFuture0801
1 Replies

2. HP-UX

Unable to edit the sudoers file using script

Hi All, I've made a script in order to delete the users. The script is deleting the users and removing its entry from the /etc/sudoers however it is changing the permissions of the /etc/sudoers file to the user from which it is executing the script. #!/bin/ksh #set -x print "The script... (2 Replies)
Discussion started by: Kits
2 Replies

3. Shell Programming and Scripting

Script to insert a function into a C source file

Hello, I think I need sed, but perhaps awk could help. I am trying to add a function to a C source file based off a struct declaration. for example: struct Rational { int numerator; int denominator; }; becomes struct Rational (4 Replies)
Discussion started by: afulldevnull
4 Replies

4. Shell Programming and Scripting

ksh script to create a generic csv file from different source formats

Hi all, I have a requirement to create a "superset" file out of a number of different sources with some different and some same columns. We intend to have a manually updateable SuperSetCols.csv which would look like "ColA","ColB","ColC","ColD","ColE","ColF","ColG" so someday we may add... (3 Replies)
Discussion started by: Leedor
3 Replies

5. UNIX for Advanced & Expert Users

Automated SCP script passing password to preserve source file timestamp

Hi My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file. By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Discussion started by: skumar75
1 Replies

6. Shell Programming and Scripting

Rsync help - unable to delete the Source file

Hi All, I am facing problem deleting Source while using the rsync command. rsync --include=*`date --date="-1 day" \+\%Y\%m\%d`* --include=*`date +\%Y\%m\%d`* --exclude=* --delete-after -auvb -e ssh USER@SERVER:SOURCE DESTINATION However the sync happens but not the deletion of the source... (1 Reply)
Discussion started by: amitkhiare
1 Replies

7. Shell Programming and Scripting

Different behaviour when running script as source file

Hi all, OS: Solaris 10 I've written a script to scan the oratab file and give me a list of Oracle SIDs to choose from, and obviously in order to set the ORACLE_SID environment variable from within a script for the current shell, the script must be run as a source file. When I run it as a... (1 Reply)
Discussion started by: longjon
1 Replies

8. Shell Programming and Scripting

source a property file in script give error

I have sourced a property file in my script like this to load some variables in the script Then i am able to echo all the property file values inside script but the script is not able to recognize other unix commands #!/bin/bash . build.properties mkdir build i am getting error ... (3 Replies)
Discussion started by: codeman007
3 Replies

9. Shell Programming and Scripting

Source Env file in the Shell Script

Hi I am having a script which sets the application environment. In this script i am sourcing the applications env file, when i am debugging the script i see its executing all the environment values and all the variable values are set properply. Once this main shell script executes, then... (4 Replies)
Discussion started by: umakanthly
4 Replies

10. Shell Programming and Scripting

Tidy shell script source file

Hi all, Is there a tool to tidy up shell script source file and reformat it. Preferably I am looking for a perfect tool to do this. Also I have heard it is possible to do with emacs editor but unfortunately it is looking very different and new from vi. Emacs is new to me and I could not find... (1 Reply)
Discussion started by: meharo
1 Replies
Login or Register to Ask a Question