Log function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log function
# 15  
Old 03-08-2007
Quote:
Originally Posted by Ernst
mW = 10dBm/10
mW = 10dBm/10
mW = dBm(10/10)
mW = dBm

In other words, multiplying a number by 10 and then dividing the result by 10 results in the original number. Smilie

So, using an alternate formula...
Code:
$ cat calc2
#! /usr/bin/ksh
bc -l |&
print -p scale=6


while read dbm?"enter dBm -->  "; do
        print -p  "e(($dbm-30)*l(10)/10)"
        read -p watt
        echo "dBm = $dbm     watt = $watt"
done
echo
exit 0
$ ./calc2
enter dBm -->  29.216870
dBm = 29.216870     watt = .835001
enter dBm -->  30.008670
dBm = 30.008670     watt = 1.001997
enter dBm -->

# 16  
Old 03-16-2007
Quote:
Originally Posted by Ernst
How do i write a code to convert watt to dBm and vice versa?
1o log(w) + 30 = dBm

Thanks!
nawk 'BEGIN { w = 0.1; print 10*log(w) + 30 }'
# 17  
Old 03-19-2007
Function call

I have a function check_ok in my abc.sh. which return me 1 or 0 . I want to call this fuction through other shell script. this shell also send two parameter to calling function.
Can you please tell me how. I am very new in unix.



#!/bin/bash

date_equal()
{

sqlplus -silent rep/qpalwo@cbi <<END
set pagesize 0 feedback off verify off heading off echo off serverout on size 100000
DECLARE
date1 DATE:=NULL;
date2 DATE:=NULL;
BEGIN
DBMS_OUTPUT.enable(100000);
select hdsg.HLD_DI_SRC_GRP_DATE into date_1 from di_hold.HOLD_DI_SRC_GRP hdsg where hdsg.HLD_DI_SRC_GRP_NAME = $1;

select hdsg.HLD_DI_SRC_GRP_DATE into date_2 from di_hold.HOLD_DI_SRC_GRP hdsg where hdsg.HLD_DI_SRC_GRP_NAME = $2;

select trunc(sysdate) into current_date from dual;
IF current_date = date_1 and current_date = date_2
THEN
DBMS_OUTPUT.put_line('1');
ELSE
DBMS_OUTPUT.put_line('0');
END IF;
END;
/
exit;
END
# 18  
Old 03-19-2007
Quote:
Originally Posted by Jamil Qadir
I have a function check_ok in my abc.sh. which return me 1 or 0 . I want to call this fuction through other shell script. this shell also send two parameter to calling function.
Can you please tell me how. I am very new in unix.



#!/bin/bash

date_equal()
{

sqlplus -silent rep/qpalwo@cbi <<END
set pagesize 0 feedback off verify off heading off echo off serverout on size 100000
DECLARE
date1 DATE:=NULL;
date2 DATE:=NULL;
BEGIN
DBMS_OUTPUT.enable(100000);
select hdsg.HLD_DI_SRC_GRP_DATE into date_1 from di_hold.HOLD_DI_SRC_GRP hdsg where hdsg.HLD_DI_SRC_GRP_NAME = $1;

select hdsg.HLD_DI_SRC_GRP_DATE into date_2 from di_hold.HOLD_DI_SRC_GRP hdsg where hdsg.HLD_DI_SRC_GRP_NAME = $2;

select trunc(sysdate) into current_date from dual;
IF current_date = date_1 and current_date = date_2
THEN
DBMS_OUTPUT.put_line('1');
ELSE
DBMS_OUTPUT.put_line('0');
END IF;
END;
/
exit;
END

First thing is please open a new thread for your new request.

You can invoke the "abc.sh" from your other shell script like:
abc.sh arg1 arg2

In you abc.sh, make your function use these arguments as $1,$2 ... and return 1 or 0.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

2. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

3. Shell Programming and Scripting

Print the one function's log to the screen

c() { if something failed;then echo "failed" exit 1 fi } f() { functinona #if something failed call "c" functionb #if something failed call "c" } f > log 2>&1 #put the log to file not print on the screen I want all the stdout/stdrr to the log file... (3 Replies)
Discussion started by: yanglei_fage
3 Replies

4. Shell Programming and Scripting

Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar. Input to the script is file name and file directory (where file is located) I am reading the input parameters as follows: FILENAME=$1 FILEDIR=$2 I have created 3 functions that are as follows: 1) gunzip file 2) unzip file... (2 Replies)
Discussion started by: pinnacle
2 Replies

5. Shell Programming and Scripting

Function output to log file

Hi I have a shell script that does a whole bunch of things. For the sake of simplicity, assume it runs commands one two and three. What i ultimately need is the ability to display the output of the entire script on the screen as well as capture the output in a file. When I try to do it in the... (3 Replies)
Discussion started by: rch
3 Replies

6. Shell Programming and Scripting

Log function.

I have to make a log function which will take any statement and write it to a file along with the time stamp.Right now I have the following code: log() { echo "`date` `hostname`: $1" >> logfile } echo "Some statement." log "Some statement." This way I can see "Some... (7 Replies)
Discussion started by: chacko193
7 Replies

7. Shell Programming and Scripting

To view the log of a function

I have a function like this validate() { /* Inside this I will do some activites } How I can redirect this function to a log file , so that If I look into that log file I can understand ,is there any error happened inside the function or not (3 Replies)
Discussion started by: saj
3 Replies

8. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

9. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

10. Programming

what is wrong with the log function in c?

Hi I looked up the reference but couldn't figure out whats wrong with my log funtions in ANSI C, need this log functions for a memory compiler, please help!! #include <stdio.h> #include <math.h> int main(void) { double d ; double logB(double x, double base); printf(" ... (2 Replies)
Discussion started by: return_user
2 Replies
Login or Register to Ask a Question