Solved

shell scripting

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

758 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