Solved

shell scripting

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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