Script S1 (which copies .dat files from one directory1 to
another directory2) run continuously.
Write Script S2 which kills S1 first, compresses all .dat
files in directory1 and directory2 successfully, re-run
Script S1 and stops self i.e. S2.
Answers were Sorted based on User's Feedback
Answer / ganesh
Hi Vipul,
Script1 have to run continuously.. So,
Script1 should be
#!bin/sh
while true
do
cp directory1/*.dat directory2/
done
Is This Answer Correct ? | 10 Yes | 1 No |
Answer / vipul dalwala
script1.sh
#!/bin/bash
cp directory1/*.dat directory2/
script2.sh
#!/bin/bash
PSIDODSCRIPT1=`ps -a | awk '/script1\.sh/ && !/awk/ {print
$1}'
SELFID=$$
kill -9 ${PSIDODSCRIPT1}
find directory1 -name '*.dat' -exec gzip {} \;
if [ $? -eq 0 ]
then
find directory2 -name '*.dat' -exec gzip {} \;
if [ $? -eq 0 ]
then
sh script1.sh
kill -9 ${SELFID}
else
exit
fi
else
exit
fi
Is This Answer Correct ? | 7 Yes | 3 No |
How to set an array in linux?
How to write an Auto scripting for deleting old files using shell script and made a cron job to run on daily basis
write a non recursive shell script that accepts any number of arguments and prints them in the reverse order
What is scripting autism?
Explain about shebang?
Why is used in shell scripting?
Write the syntax for "if" conditionals in linux?
Write a shell script in Linux to shift all characters in a file forward by five characters. (Thus “a” becomes “f’”).
2 Answers Ignou, Tripura Info,
What is awk in shell scripting?
What is meant by $1 in shell script?
What are the various stages of a linux process it passes through?
Which is best institute for testing tool?