09 Basic Script Elements (Input
09 Basic Script Elements (Input
: PPT/2K403/02
• General Considerations.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
operation
subroutine module
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
Input output
working
Boundary(start,stop)
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
General Considerations
5
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– Script contains three elements, the program start , the action, and
the program stop.
– General rules for creating a Script.
– Start
• The first line of any script should be the shebang (e.g # ! /bin/bash).
• This line specifies the shell program to call to execute the script.
– Commands
• Shell scripts in general rely on the echo command as the most
common solution to produce output.
– Stop
• At last it defines the script exit status with exit value , which informs
parents how the script was terminated.
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
start
stop
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Arithmetic Operations
9
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
– With the expr command only five operators are available ”+”,”-”,
”*”,”/”, and “%”.
– Using the Bash built –in let :
• let A =“$B + 10”
© CMS INSTITUTE, 2004. All rights reserved. No part of this material may be reproduced, stored or emailed without the prior permission of Programme Director, CMS Institute
Revision no.: PPT/2K403/02
11