-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenspindens
executable file
·66 lines (58 loc) · 1.37 KB
/
genspindens
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/bash
# Default values
int_value=50
file_arg=""
script_name=$(basename "$0")
COMMAND_LIST=$(cat <<EOF
1
3
y
4
$int_value
5
7
10
11
EOF
)
# this command list works like this:
# 1 -> enter the type of plot
# 3 -> select spindens
# y -> accept the spindens plot
# $int_value -> select the grid size
# 5 -> select the output format
# 7 -> select the cube output format
# 10 -> generate the cube
# 11 -> exit
# Help message
usage() {
echo "Usage: $script_name -f <file> [-n <integer>]"
echo " -f <file> Specify the file (required)"
echo " -n <integer> Specify an integer (optional, default is 50)"
echo " -h Display this help message"
}
# Parse arguments
while getopts "f:n:h" opt; do
case $opt in
f) file_arg="$OPTARG" ;;
n) int_value="$OPTARG" ;;
h) usage
exit 0 ;;
\?) echo "Invalid option: -$OPTARG" >&2
usage
exit 1 ;;
:) echo "Option -$OPTARG requires an argument." >&2
usage
exit 1 ;;
esac
done
# Check if the required argument -f is provided
if [ -z "$file_arg" ]; then
echo "Error: -f <file> argument is required."
usage
exit 1
fi
# Construct the command now that file_arg is set
orca_plot_command="/run/media/vport/data/orca/orca_plot $file_arg -i"
# Main script logic
echo "$COMMAND_LIST" | $orca_plot_command > /dev/null 2>&1