K script not running / syntax problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting K script not running / syntax problem
# 1  
Old 03-10-2010
K script not running / syntax problem

Hi,

I have following K script, that is in rc0.d directory to be run on shutdown. It's linked using the 'ln' command to init.d.Can anyone tell me as to why it's not running, or if i have incorrect syntax?I get:

Code:
"test: argument expected
type=uname -p 
+ [ uname -p=sparc ]"

When running it with sh -x

Thanks..


Code:
#!/bin/sh
#
# Clear out the path_to_install file on shutdown
#
# Minor number issue, 32 bit programs
#
#
#


type='uname -p'
if [ $type="sparc" ]
                        then
                                devfsadm -c disk -C -v
                                cd /etc
                                cp  path_to_inst backup_path_inst
                                sed -e '/"ssd"/d' backup_path_inst > path_to_inst

                        else
                                devfsadm -c disk -C -v
                                cd /etc
                                cp  path_to_inst backup_path_inst
                                sed -e '/"sd"/d' backup_path_inst > path_to_inst

                        fi

done

exit 0


Last edited by Scott; 03-10-2010 at 10:01 AM.. Reason: Please use code tags
# 2  
Old 03-10-2010
Use backticks..

Code:
type=`uname -p`

# 3  
Old 03-10-2010
Code:
# execute uname (you only put the literal string "uname -p" into a variable)
# spaces either side of =
# in the if, quote the variable, no need to quote sparc
# probably wouldn't use the name "type" for a variable
...
hwtype=$(uname -p)
if [ "$hwtype" = sparc ]; then

...

Please don't use backticks Smilie
# 4  
Old 03-10-2010
Quote:
Originally Posted by scottn
Code:
# execute uname (you only put the literal string "uname -p" into a variable)
# spaces either side of =
# in the if, quote the variable, no need to quote sparc
# probably wouldn't use the name "type" for a variable
...
hwtype=$(uname -p)
if [ "$hwtype" = sparc ]; then

...

Please don't use backticks Smilie

Thanks for the help, but i get the following with hwtype implementation:

`hwtype=$' unexpected
# 5  
Old 03-10-2010
Please use backticks SmilieSmilieSmilie

(what is the meaning of "K" script?)
# 6  
Old 03-10-2010
Quote:
Originally Posted by scottn
Please use backticks SmilieSmilieSmilie

(what is the meaning of "K" script?)
Sorry Scott,

Still getting

`hwtype=$' unexpected

with backticks. (This is or Solaris 10)

A script that is executed on a shutdown etc. S script would be a startup?? scripts in rc0.d directory
# 7  
Old 03-10-2010
I already worked out it's Solaris!

Backticks work fine.
Code:
#!/bin/sh

hw=`uname -p`
echo $hw

sparc

Please post your updated code.

Yes, S is for startup (and K for shutdown) Not sure there would be much point in putting an S script in runlevel 0. The K script would go wherever it was appropriate to stop whatever you're trying to stop.

Last edited by Scott; 03-10-2010 at 10:28 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Check Syntax of Shell Script without Running

Hi Everyone, Is there any way ( generic) to check syntax of Shell Scripts without running it?? (4 Replies)
Discussion started by: roy121
4 Replies

2. UNIX for Dummies Questions & Answers

Problem with test syntax in script

Hi guys here i'm again with more question The code below try to find an user and write everything about him if exist, so my problem appear on line of test, where the program test if the user has secondary groups related. The rest it's clear # usugrup.sh lista todas las caracteristicas de un... (3 Replies)
Discussion started by: Newer
3 Replies

3. Shell Programming and Scripting

Problem on running a script

Hi all, Running follow command on terminal; $ glance -T cloudlive -I ubuntu -K ubuntu123 -N \ http://127.0.0.1:5000/v2.0/OpenX add name="cirros" is_public=true \ container_format=ovf disk_format=raw < \ /srv/cirros-0.3.0-x86_64-disk.img It works without problem. Putting it on a... (5 Replies)
Discussion started by: satimis
5 Replies

4. Emergency UNIX and Linux Support

Problem with running Ghost Script

I have getting problem with running gs on a non global zone. This is new zone. Seems something to do with library, but I am not getting correct pointer. -bash-3.00$ which gs /usr/local/bin/gs -bash-3.00$ gs ld.so.1: gs: fatal: libcairo.so.2: open failed: No such file or directory Killed... (3 Replies)
Discussion started by: solaris_1977
3 Replies

5. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

6. Shell Programming and Scripting

Problem with running the remote script

Hi All, I am running a script which is present on remote machine using ssh command. the remote script is failing when try to load a property file. It says file does not exist. Any idea what should be the problem for this. Thanks Supriya. (7 Replies)
Discussion started by: supriyabv
7 Replies

7. UNIX for Dummies Questions & Answers

problem running script

hey, i'm trying to run several processes due 2 loops : the code is: cd ${TIBCO_HOME}/tra/domain/${DOMAIN}/application/ for app_name in ls * do echo $app_name if && && ; then exit else echo $app_name cd $app_name pwd for ps_name in ls *.sh do echo... (2 Replies)
Discussion started by: ohadr
2 Replies

8. UNIX for Advanced & Expert Users

Problem in running an AWK script

Hi Everyone, I am required to write an AWK script that can be run from any directory. This script finds subscription rates for each subscriber at an interval of 10 mins. I want that just by copy pasting the whole script in shell prompt and giving the input arguments, script must work. Currenty... (4 Replies)
Discussion started by: rachana8p
4 Replies

9. Shell Programming and Scripting

problem with script and syntax error message

Hi I have the following script and have problem debugging the problems. The function of this script is to make sure the entire file is being received (the filesize of a data is not changing after 20 seconds) and start moving the file to another directory. This script should be started every 30mins.... (5 Replies)
Discussion started by: ReV
5 Replies

10. Shell Programming and Scripting

Problem in Running Script

Hi friends, i have written one small script named as "size.sh"..... while running its giving syntax error at line no 2: 'str=$' unexpected. How to run this file ??? please help me. file content is : ----------------------------- #!/bin/sh str=$( df -k | grep /usr/local)... (14 Replies)
Discussion started by: samfrance
14 Replies
Login or Register to Ask a Question