LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-30-2010, 03:41 AM   #1
dhanushkag
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 0
Can't source file by shell script in Ubuntu 10.04


Hi, Please advise

When I try to execute my script its getting error

.........................................
tape_restore.sh: 40: source: not found
tape_restore.sh: 41: source: not found
tape_restore.sh: 42: source: not found

.................................

But in Redhat I can run same script . My script as follows.

**************************************************
SCRIPT_HOME=/home/dhanushka/project/mChoise_Recharge/scripts/scriptfw
TAPE_DRV=/dev/st0

source $SCRIPT_HOME/conf/system.conf
source $SCRIPT_HOME/src/logging.bin
source $SCRIPT_HOME/src/tape_backup.bin


*****************************************************

Please help me !!
 
Old 07-30-2010, 04:27 AM   #2
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Hi

I suspect that the source package isn't installed.

Try running the line below at the terminal and post the output:

Code:
$ source $SCRIPT_HOME/conf/system.conf
Obviously add in the full path for $SCRIPT_HOME.
 
Old 07-30-2010, 11:21 PM   #3
dhanushkag
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Yas,

I tried that way(gave absolute path) too. But Still error is the same

dhanushka@dhanushka-laptop:~/project/mChoise_Recharge/scripts/scriptfw/bin$ sh tape_restore.sh
tape_restore.sh: 40: source: not found

But I can source that file through command line .

dhanushka@dhanushka-laptop:~$ source /home/dhanushka/project/mChoise_Recharge/scripts/scriptfw/conf/system.conf
dhanushka@dhanushka-laptop:~$
 
Old 07-31-2010, 07:43 AM   #4
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
source is a bashism. Ubunut uses dash as its /bin/sh. dash doesn't support source. If you want to use bash change the shebang at the top of your script to #!/bin/bash
If you want to make your scripts portable use . instead.
Code:
SCRIPT_HOME=/home/dhanushka/project/mChoise_Recharge/scripts/scriptfw
TAPE_DRV=/dev/st0

. $SCRIPT_HOME/conf/system.conf
. $SCRIPT_HOME/src/logging.bin
. $SCRIPT_HOME/src/tape_backup.bin
 
Old 08-08-2010, 06:35 AM   #5
dhanushkag
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Smile

Hi Andy ,

Its worked !!!!
Thank you very much
 
  


Reply



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
how to execute Source command in a shell script UltraSoul Linux - General 3 09-23-2010 10:13 AM
using source inside a shell script DEF. Programming 8 11-18-2009 05:52 PM
Tidy shell script source file mmn357157 Linux - General 8 12-20-2008 07:33 PM
Need a shell script to turn a lined file into a comma seperated file Thaidog Linux - General 8 03-08-2008 07:19 PM
Need a script to search and replace text in file using shell script unixlearner Programming 14 06-21-2007 10:37 PM

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

All times are GMT -5. The time now is 04:48 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
Open Source Consulting | Domain Registration