how to call another program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to call another program
# 1  
Old 07-02-2008
how to call another program

Hi,
I would like to know how to call a program "cmp_size" ... where to put in progam to run it

ex: program checkdisk is below, and it will call a nother problem "cmp_size"
Do I just put the cmp_size program at the end of this program.
Thank you very much,

# check all directory for size
#!/bin/sh
# chdsk2 - multiple directories & dir . -spectific cutoffs
du_it()
{
# $1 = cutoff in blocks for new directories
# $2 = cutoff as block change for old directories
# $3 = starting directory; $4 = flags to du
du $4 $3 > du.tmp
cat du.tmp|xargs -n2 cmp_size $1 $2 du.sav
cat du.tmp >> du.log; rm du.tmp
}
umask 077
rm -f du.log du.tmp 2>&1 >/dev/null
if [! -s du.save]; thne
echo "run_cmp:can't find old data file; run du_init."
exit 1
fi
echo "Daily disk usage report for `date`"; echo ''
df
echo ''; echo "Old\tNew"
echo "Size\tSixe\tDirectory Name"
eho "--------------------------------------------------"
du_it 40 100 /datadump/
du_it 1 1 /var
du_it 1 1000 /home/\* -s
echo "-------------------------------------------------"
echo ''
mv -f du.log du.sav
exit 0
# 2  
Old 07-02-2008
What do you mean
Quote:
a program "cmp_size"
?
# 3  
Old 07-02-2008
Yes, a program "cmp_size"

#!/bin/sh
# cmp_size - compare old and new directory size
# $1 (limit)=min. size for new dirs to be included in report
# $2 (dlimit)=min. size change for old dirs to be included
# $3 (sfile)=pathname for file with yesterday's data
# $4 (csize)=current directory size
# $5 (file)=pathname of directory
# osize=privious size (extracted from sfile)
# diff=size difference between yesterday and today

if [$# -ld 5];then
echo "Usage: cmp_size newlim oldlim data_file size dir"
exit 1
fi
# save initial parameters
limit=$1; dlimit=$2; sfile=$3; file=$5; csize=$4
# get yesterday's data
osize=`grep "$file\$" $sfile | awk '{print \$1}'`
if [ -z "osixe"]; then # it's a new dir.
if [$csize -ge $limit ]; then # report if size >= limit
echo "new\t$csize\t$file"
fi
exit 0
fi
# compute the size change from yesterday
if [ $osize -eq $csize]
then
exit 0
elif [ $osize -gt $csize]
then
diff=`expr $osize - $csize`
else
diff=`expr $csize - $osize`
fi
# check if size change is big enough to report on
if [ $diff -ge $dlimit]; then
echo "$osize\t$csize\tfile"
fi
# 4  
Old 07-02-2008
Code:
/path/to/script.sh $param

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with Execl system call in a C program?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: "Your a7.c program should use printf to print a nice message. (You can decide what to say.) Then the process... (9 Replies)
Discussion started by: miniviking10
9 Replies

2. Programming

call program

I would need to call the program 'ethtool' in my C++ program, does anyone know how to do that (if its even possible)? (1 Reply)
Discussion started by: Freaky123
1 Replies

3. Shell Programming and Scripting

How to call a stored procedure from shell program?

How to call a stored procedure from shell program (1 Reply)
Discussion started by: noorm
1 Replies

4. Shell Programming and Scripting

Call a mainframe program

Is it possible to call a mainframe program in UNIX script. I am using HP-UNIX. If so can any let me know the way to do it. (1 Reply)
Discussion started by: atlantis
1 Replies

5. UNIX for Dummies Questions & Answers

How to run two commands from a exec call in a c program

Hi, I have to run two commands one after another from a c program. How can i do this with exec system calls. i tried giving them as argument to execv but it is not working.please help thanks (3 Replies)
Discussion started by: suryashikha
3 Replies

6. Programming

A question about the system call mount in a C program

Dear all, Currently I'm working on a C program (OS = ubuntu 9.0.4)in which a USB key will be mounted and umounted for several times. I read the man page of the mount system call. I use the following test code #include <sys/mount.h> int main(int argc, char *argv) { if... (5 Replies)
Discussion started by: dariyoosh
5 Replies

7. Programming

how to call c executable inside c program??

hi guys i have only basic knowledge of c so guys plz help me ..... i want 2 call c executable which requires file name as argument and i need to modify file contents before calling that executable now my question is how can i call this c executable inside another c program with arguments ?? i... (9 Replies)
Discussion started by: zedex
9 Replies

8. Shell Programming and Scripting

Call C Program From Shell Script

Hi, Could anybody please let me know how to call a C_Program from shell script. I know through command "system" we can call shell script from C program. Awaiting response. Thanks and regards, Chanakya M (4 Replies)
Discussion started by: Chanakya.m
4 Replies

9. Shell Programming and Scripting

how to call awk in a csh Program

Hi Friends, Could you pleas help me out.. I have an awk program which works fine while running it in the command prompt. The awk program is =============== awk 'BEGIN { format="head -%d M2_Sales_N01.txt |tail -%d >M2_Sales_N01_%02d.txt\n" n=0 m=0 } { if (n==0) { tmp=$1 n=1 }... (5 Replies)
Discussion started by: bikas_jena
5 Replies

10. Linux

How to call a proc file from *.c program?

Hi, I am new to Linux programming. As part of learning, I need to create a *.c program where we call certain /proc files (i.e. such as meminfo, version, uptime, etc...) from our program. Can anyone point me to a simple program on how one would do this (i.e. can you directly call uptime() or... (4 Replies)
Discussion started by: pat_and_cami
4 Replies
Login or Register to Ask a Question