Unix Technical Forum

Startup script, Solaris 8 can't find 'source' command

This is a discussion on Startup script, Solaris 8 can't find 'source' command within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> This script works fine if the OS is up and running, but if I reboot the machine I get ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > Sun Solaris Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2008, 06:23 AM
Dj
 
Posts: n/a
Default Startup script, Solaris 8 can't find 'source' command

This script works fine if the OS is up and running, but if I reboot
the machine I get an error saying that 'source not found.'

Here's my script:

#!/bin/csh
source /usr/appenv/.main_source
/usr/bin/su cindly -c
"/ccm/Beta/is/procedures/bloomberg/Start_Blg_Servers.pl"

I understand that it can't find the 'source' command, but don't know
how to fix it. Any ideas? Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-12-2008, 06:23 AM
Tony Curtis
 
Posts: n/a
Default Re: Startup script, Solaris 8 can't find 'source' command

>> On 18 Aug 2003 09:08:48 -0700,
>> scwoodal@hotmail.com (Dj) said:


> This script works fine if the OS is up and running, but
> if I reboot the machine I get an error saying that
> 'source not found.'


> Here's my script:


> #!/bin/csh source /usr/appenv/.main_source /usr/bin/su
> cindly -c
> "/ccm/Beta/is/procedures/bloomberg/Start_Blg_Servers.pl"


> I understand that it can't find the 'source' command,
> but don't know how to fix it. Any ideas? Thanks in
> advance.


Solaris runs scripts in the rc?.d directories through
/sbin/sh.

The Solaris FAQ covers this (somewhat incidentally):

http://www.science.uva.nl/pub/solari...is2.html#q3.19

hth
t
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-12-2008, 06:23 AM
Tony Walton
 
Posts: n/a
Default Re: Startup script, Solaris 8 can't find 'source' command

Dj wrote:
> This script works fine if the OS is up and running, but if I reboot
> the machine I get an error saying that 'source not found.'
>
> Here's my script:
>
> #!/bin/csh
> source /usr/appenv/.main_source
> /usr/bin/su cindly -c
> "/ccm/Beta/is/procedures/bloomberg/Start_Blg_Servers.pl"
>
> I understand that it can't find the 'source' command,


Which is a csh builtin

> but don't know
> how to fix it. Any ideas? Thanks in advance.




Startup scripts (assuming you mean a startup script in /etc/init.d and
/etc/rc?.d) should be Bourne shell scripts. The script that runs them
(/etc/rc3 for instance) passes the script to /sbin/sh unless the script
name ends with .sh (in which case it "dots" it - the Bourne/Korn version
of sourcing it) without passing it to /bin/sh).

for f in /etc/rc3.d/S*; do
if [ -s $f ]; then
case $f in
*.sh) . $f ;;
*) /sbin/sh $f start ;;
esac
fi
done
fi



If you really, really need a csh startup script (and I'm pretty much at
a loss to imagine why you would), write a Bourne shell script that runs
it (a wrapper) and put the Bourne shell script in /etc/rcwhatever.d

--
Tony

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-12-2008, 06:23 AM
Greg Andrews
 
Posts: n/a
Default Re: Startup script, Solaris 8 can't find 'source' command

scwoodal@hotmail.com (Dj) writes:
>
>The file I'm trying to source has things like "setenv" in it, and I
>don't think if it runs as /bin/sh it will understand the setenv.
>


That's right. You need to do something other than make the
first line '#!/bin/csh' if you want your script run by csh
instead of sh.


-Greg
--
Do NOT reply via e-mail.
Reply in the newsgroup.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-12-2008, 06:23 AM
Steve Bellenot
 
Posts: n/a
Default Re: Startup script, Solaris 8 can't find 'source' command

In article <8fd15dbf.0308181313.8de65f7@posting.google.com> ,
Dj <scwoodal@hotmail.com> wrote:
>Tony Walton <tony.walton@s-u-n.com> wrote in message news:<3F40FBF3.6000109@s-u-n.com>...
>> Dj wrote:
>> > This script works fine if the OS is up and running, but if I reboot
>> > the machine I get an error saying that 'source not found.'
>> >
>> > Here's my script:
>> >
>> > #!/bin/csh
>> > source /usr/appenv/.main_source
>> > /usr/bin/su cindly -c
>> > "/ccm/Beta/is/procedures/bloomberg/Start_Blg_Servers.pl"
>> >
>> > I understand that it can't find the 'source' command,

>>

>The file I'm trying to source has things like "setenv" in it, and I
>don't think if it runs as /bin/sh it will understand the setenv. New
>to Sun administration so please bare with me. That script you wrote at
>the end of your post makes little to no sense for me.


Well this might do it.
1. cp .main_source to .main_source.sh
2. edit .main_source.sh changing lines like
setenv FOO BAR
to two lines like (no spaces on either side of the ='s)
FOO=BAR
export FOO
3. Change your script to
# note the beginning dot on the next line, the dot is like source
.. /usr/appenv/.main_source.sh
/usr/bin/su cindly -c "/ccm/Beta/is/procedures/bloomberg/Start_Blg_Servers.pl"
--
http://www.math.fsu.edu/~bellenot
bellenot <At/> math.fsu.edu
+1.850.644.7189 (4053fax)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-12-2008, 06:23 AM
Tony Walton
 
Posts: n/a
Default Re: Startup script, Solaris 8 can't find 'source' command

Dj wrote:
> Tony Walton <tony.walton@s-u-n.com> wrote in message news:<3F40FBF3.6000109@s-u-n.com>...


>>
>>If you really, really need a csh startup script (and I'm pretty much at
>>a loss to imagine why you would), write a Bourne shell script that runs
>>it (a wrapper) and put the Bourne shell script in /etc/rcwhatever.d

>
>
> The file I'm trying to source has things like "setenv" in it, and I
> don't think if it runs as /bin/sh it will understand the setenv.


Correct - it's a csh script. Either (preferably, IMHO) re-write it as a
Bourne shell script, or, as I suggested, create a Bourne shell script
which runs your csh script and place that Bourne shell script in
/etc/rcwhatever.d


New
> to Sun administration so please bare with me. That script you wrote at
> the end of your post makes little to no sense for me.


Can I suggest you find out quite a lot more about shell programming and
system administration before you do *anything* else while logged in as root?

Regards

--
Tony

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:14 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com