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.
Answer Posted / 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 |
Post New Answer View All Answers
Write down the syntax of "for " loop
What is the equivalent of a file shortcut that we have a window on a linux system?
What is bash command used for?
Explain about login shell?
What are the different communication commands available in the shell?
How to find duplicate record in file using shell script?
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
Write a script to print the first 10 elements of fibonacci series.
What is the use of "$#" in shell scripting?
What are different types of shell?
Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.
madhar chod unix ke 10 commands dhang se likh nahi sakta hai
Which scripting language is best for automation?
write a shell script to check the failed jobs?
What does .sh file contain?