Help with reading and calling a command in a script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with reading and calling a command in a script
# 1  
Old 12-04-2013
Help with reading and calling a command in a script

The problem I am having now is calling and reading a command and The Main script reads the data file and passes the input to the two calculation scripts, and than output to a file.
1.
Quote:
The contents of the input data file shown below:
1
8
22
43
89
283
120
212
1043
100
287
Quote:
2.
Sample output of the data that would follow your output header.

Centigrade Temperature Fahrenheit Temperature
-------------------------------- ---------------------------------
1 33.80
8 46.40
22 71.60
43 109.40
89 192.20
283 541.40
120 248.00
212 413.60
1043 1909.40
100 212.00
287 548.60

Fahrenheit Temperature Centigrade Temperature
-------------------------------- ---------------------------------
1 -17.22
8 -13.33
22 -5.55
43 6.11
89 31.66
283 139.44
120 48.88
212 100.00
1043 561.66
100 37.77
287 141.66



The Main Script
-----------------
Code:
input=inputfilepj3
output=outfilepj3
 
echo "*** Converting between the different temperature scales ***"
echo "1. Convert Celsius temperature into Fahrenheit"
echo "2. Convert Fahrenheit temperature into Celsius"
echo "Select your choice (1-2): "
read choice
case "$choice" in
1)
   echo "Centigrade Temperature      Fahrenheit Temperature " > ${output};
   echo "-----------------------      -----------------------" >> ${output}
   CtoF $var
;;
2)
   echo "Fahrenheit Temperature      Centigrade Temperature " > ${output}
   echo "-----------------------      -----------------------" >> ${output}
   FtoC $var
;;
*)
   echo "Please select 1 or 2"
   exit 1
esac

CtoF
--------

Code:
 
echo -e "******************Calculating Celsius into Fahrenheit********"
 
echo -n "Enter temperature (C) : "
read tc
# formula Tf=(9/5)*Tc+32
tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
echo "$tc C = $tf F"

FtoC
------
Code:
 
echo -e "**************Calculating Fahrenheit into Celsius*********"
 
echo -n "Enter temperature (F) : "
read tf
#formula Tc=(5/9)*(Tf-32)
tc=$(echo "scale=2;(5/9)*($tf-32)" |bc)
echo "$tf = $tc"

# 2  
Old 12-04-2013
You can do this in one script.
# 3  
Old 12-04-2013
Quote:
Originally Posted by blackrageous
You can do this in one script.
The professor has specifically said that you have to make 3 Scripts, One the main script, and the other two are calculations.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script run curl command calling cyber-Ark RESTAPI

Hi All, We have a requirement to Integrate Cyber-Ark with Informatica . Basically cyberark will contain the username and password for Database. First step will be 1)In shell Script run curl command calling cyber-Ark RESTAPI requesting the credentials and store the secret in a variable. ... (0 Replies)
Discussion started by: Praveena9102
0 Replies

2. Shell Programming and Scripting

Calling another Script from Command Line in UNIX

Hi all, I am having problem in understanding the following line of code .. /home/rmsbatch/autoscript/autorms.ksh dc_load_main.ksh -q belk_dc_load_tran_data.seq What's being done here ? what does "-q" means ? What does ".seq" file means in unix "belk_dc_load_tran_data.seq" Please... (3 Replies)
Discussion started by: LoneRanger
3 Replies

3. UNIX for Dummies Questions & Answers

Calling Macros in UNIX command

Hi .. I have created a sql macro, i want to execute this through ksh in putty.ie) sql.ksh will contain the macro query ,once i call this ksh ,the macro should trigger. I am able to write a macro : for ex: create macro macro_name (sel * from db_tablename) execute macro_name. Could... (1 Reply)
Discussion started by: Kalaiselvi66
1 Replies

4. Shell Programming and Scripting

SendEmail - Script reading database file with sleep command

Hello, I would like to send email message to my mail list. I have been running linux based server and I submitted this process manually up to now. I would like to send each individual with a shell script. In ssh panel, I tested below command and it works smoothly. sendEmail -t... (1 Reply)
Discussion started by: baris35
1 Replies

5. Shell Programming and Scripting

Reading command line options from bash script

I have the following code and I am calling it using ./raytrac.bash -u and getting problems. For some reason opt_usage is still 0. opt_usage=0 iarg=0 narg=$# while (($iarg < $narg)) do (( iarg = $iarg + 1 )) arg=$argv usrInputFlag=`echo $arg | awk '/=/ {print 1}; ! /=/... (22 Replies)
Discussion started by: kristinu
22 Replies

6. Shell Programming and Scripting

Reading function calling statement from a file

Hi, I have a shell script 'sample.sh' which has some functions as below. #fun1 fun1() { date } #fun2() { echo hi } I want to run these functions as background processes and also redirect the output to a file. My function calling statements are in a different file 'sample.cfg' as... (3 Replies)
Discussion started by: rama_kodam
3 Replies

7. Shell Programming and Scripting

Calling bash command in perl script

Hi, I have tried several times but failed, I need to call this script from the perl script. This one line script will be sent to /var/tmp/error Bash command: /usr/openv/netbackup/bin/admincmd/bperror -backstat -l -hoursago 12 |awk '{ print $19, $12, $14, $16}'|grep -vi default|sort >... (12 Replies)
Discussion started by: sQew
12 Replies

8. Shell Programming and Scripting

reading fixed length flat file and calling java code using shell scripting

I am new to shell scripting and I have to to the following I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file. Like the following str00001.txt StoreName emailaddress location... (3 Replies)
Discussion started by: willywilly
3 Replies

9. Shell Programming and Scripting

calling sub-script in a command while

Hi, I am writting a script reading a liste of files from a file-list using the command while read NEW_LINE, and calling a "ksh" shell for each line. My shell is like beside, and only the first line of the file-list of "/app/admin/file-list.txt" is actually processed. It seems that calling a... (2 Replies)
Discussion started by: astjen
2 Replies

10. Shell Programming and Scripting

reading command output from shell script

Hi List, How to read the output of a command executed from a script. For ex. sample_scritp.sh ------------- useradd testuser1 password testuser1 .... ..... -------------- This prompts for "password", and "confirm password", for which i need to give the values from script. Can... (4 Replies)
Discussion started by: sri b
4 Replies
Login or Register to Ask a Question