shell script to convert Celsius to Fahrenheit
I need a small script to convert Celsius to Fahrenheit. I have this one but it terminates after input and doesn't show the result. If it works at all I can't tell. Can someone correct it for me or give me one that will work?
Quote:
Paul |
Hi,
What is the problem you're having with the above script? Works nicely on my side: Code:
$ ./temperature.converter.sh I would change this line Code:
echo "$tf = $tc" Code:
echo "$tf F = $tc C" |
The problem is my terminal window closes after I input my temp. it pauses to accept my input to enter the value for temp but then terminates and the terminal window closes
|
Hi,
Quote:
- Do you open a terminal first and then execute it? - Did you make a shortcut to the script and (double)click on that? - ? |
Quote:
|
Hi,
Quote:
You could add a piece of code that waits for a key press before it exits (the bold part): Code:
#!/bin/bash Quote:
I.e Code:
/full/path/to/temp.sh - the first line of the script reads #!/bin/bash - the script is executable (chmod 750 temp.sh). Hope this helps. |
yeah I clicked on properties and chose to execute as program.
yes, both answers were what I was looking for! Thanks, Paul |
Hi,
Quote:
BTW: Can you put up the [SOLVED] tag. first post -> Thread Tools -> Mark this thread as solved |
accuract problem
I found this thread some years later, but may-be these remarks can help...
37 Celsius gives 98.60 Fahrenheit 98 Fahrenheit gives 36.63 Celsius. I would also suggest splitting in 2 non-interactive scripts, in order to use then in other scripts - cel2far #!/bin/bash echo "2 k 9 5 / $1 * 32 + p" | dc - far2cel #!/bin/bash echo "2 k $1 32 - 5 * 9 / p" | dc |
All times are GMT -5. The time now is 09:59 PM. |