-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask2 diagnosis.sh
32 lines (27 loc) · 1.2 KB
/
task2 diagnosis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Function for permissions
permissions() {
local user=$1
local file=$2
sudo chown "$user:$user" "$file"
sudo chmod 600 "$file"
}
# Diagnosis and Prescription function
echo "Enter the patient's diagnosis and prescription:"
read -p "Enter doctor's username: " doctor_username
read -p "Enter patient's username: " patient_username
read -p "Enter diagnosis [infectious, mental, physical, critical]: " diagnosis
read -p "Enter date and time of diagnosis: " diagnosis_datetime
read -p "Enter morning medicine: " morning_med
read -p "Enter afternoon medicine: " afternoon_med
read -p "Enter dinner medicine: " dinner_med
# Update PatientDetails.txt
doctor_home="/home/$doctor_username"
patient_home="/home/$patient_username"
echo "Diagnosis: $diagnosis, Date and Time: $diagnosis_datetime" | sudo tee "$patient_home/PatientDetails.txt"
permissions "$doctor_username" "$patient_home/PatientDetails.txt"
# Update Prescription.txt
echo "Morning: $morning_med" | sudo tee "$patient_home/Prescription.txt"
echo "Afternoon: $afternoon_med" | sudo tee "$patient_home/Prescription.txt"
echo "Dinner: $dinner_med" | sudo tee "$patient_home/Prescription.txt"
permissions "$doctor_username" "$patient_home/Prescription.txt"