Solved

shell scripting

Posted on 2002-05-23
2
190 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
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 500 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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 …
Fine Tune your automatic Updates for Ubuntu / Debian
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now