Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

shell scripting

Posted on 2002-05-23
2
Medium Priority
?
197 Views
Last Modified: 2010-04-20
How would I write a script for  the scriptfile "puzzlescript"  to make the gotchascript echo back "gotcha" ?  The idea here is to set up the first script named gotcha so that when $sum and $rightsum are equal the script will echo back gotcha.  It is set up to look at and execute the scriptfile 'puzzlescript'  to see if its value is equal to $rightsum.  Puzzlescript is set up in another part of the directory and has to be written in such a way that when the gotchascript comes to run it, it triggers the echo gotcha from the gotchascript.

#!/bin/bash
#gotchascript

if [ ~/puzzle ]
then
sum=` ~/puzzle 5 10 20 $$`
rightsum=`expr 35 + $$`
if [ $sum -eq $rightsum ]
then
echo gotcha
echo
fi

What I've come up with so far is,

#!/bin/bash
#puzzlescript

sum=`expr 5 + 10 + 20 + $$`
echo $sum

but it won't cause the echo gotcha from the gotchascript
0
Comment
Question by:alphaomega232
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:jolbe13
ID: 7029937
I cant really get your point. Can you be more explicit.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 7030458
beside the missing fi statements, it would be a rare case that your script prints "gotcha", probably if your machine has a high load *and* you have plenty of time to wait ...

Both scripts use $$ to compute a number, which then is compared, that will not work.
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question