-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcopy_file.sh.in
More file actions
executable file
·39 lines (36 loc) · 958 Bytes
/
copy_file.sh.in
File metadata and controls
executable file
·39 lines (36 loc) · 958 Bytes
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
#!/bin/bash -
#===============================================================================
#
# FILE: copy_file.sh
#
# USAGE: ./copy_file.sh
#
# DESCRIPTION: Copy one file from one place to another, wait for file to
# appear.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Dilawar Singh (), [email protected]
# ORGANIZATION: NCBS Bangalore
# CREATED: Friday 09 December 2016 05:31:39 IST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
from=$1
to=$2
# Wait for file to appear for a second.
n=0
while [ ! -f $from ]; do
sleep 0.5
printf '.'
n=$((n+1))
if [[ $n == 2 ]]; then
echo "$from is not available. Timeout 1 sec. Cant copy"
break
fi
done
if [ -f $from ]; then
cp $from $to &
fi