I am trying to script simply data transfer. I would like to have the user input the source "SRC" (/Volumes/DriveName/Users/johnq123) and then name the directory that the copied information will go to, "DST" . put I can't get it to work -
Code:
#!/bin/bash
#=============================================
# data recovery attempt for HFS/HFS+ Drives
#=============================================
echo -n " "$USER", input path to source Volume User Folder, ex. /Volume/drivename/Users/"
read SRC
echo -n " "$USER", input last name and case number."
read DST
echo "Creating Destination Directory on Volume BACKUPS."
mkdir /Volumes/BACKUPS/$DST
echo "Ditto-ing Data to Destination Directory on Volume BACKUPS."
ditto $SRC/Desktop/*.* /Volumes/BACKUPS/$DST
ditto $SRC/Documents/*.* /Volumes/BACKUPS/$DST
ditto $SRC/Pictures/*.* /Volumes/BACKUPS/$DST
echo "Done."
I am trying to script simply data transfer. I would like to have the user input the source "SRC" (/Volumes/DriveName/Users/johnq123) and then name the directory that the copied information will go to, "DST" . put I can't get it to work -
"*.*" is a DOS thing, and makes little to no sense in UNIX. Try just "*". It'd also help if you told us what happened, we can't tell from here.
You might also want to try just copying the directory instead of directory/*, since the way you're doing it might mash all the files together in one giant undifferentiated directory and runs the risk of having too many arguments.
ok, so I changed the script a bit, and have included the output.
Code:
#!/bin/bash
#=============================================
# data recovery attempt for HFS/HFS+ Drives
#=============================================
echo " "$USER", input path to source Volume User Folder, ex. /Volume/drivename/Users/"
read SRC
echo " "$USER", input last name and case number."
read DST
echo "Creating Destination Directory on Volume BACKUPS."
mkdir /Volumes/BACKUPS/$DST
echo "Ditto-ing Data to Destination Directory on Volume BACKUPS."
ditto $SRC/Desktop/* /Volumes/BACKUPS/$DST
ditto $SRC/Documents/* /Volumes/BACKUPS/$DST
ditto $SRC/Pictures/* /Volumes/BACKUPS/$DST
echo "That's all she wrote..."
Code:
testuser, input path to source Volume User Folder, ex. /Volumes/drivename/Users/
/Volumes/MacHDD/Users/test1
testuser, input last name and case number.
testcase123
Creating Destination Directory on Volume BACKUPS.
Ditto-ing Data to Destination Directory on Volume BACKUPS.
That's all she wrote...
ditto: can't get real path for source
ditto: can't get real path for source
ditto: can't get real path for source
i think the issue is in
Code:
read SRC
and the input, SRC, to that being a path. i need some way to use the inputted path as the source for ditto
Besides also according to the ditto man page you even don't need to manually create the $DST directory, since it will be created automatically if it does not exist.
I also recommend to code some basic error-checking, e.g. check if the $SRC file (directory) exists.
Thank you for the help. so with all the suggestions the script works and reads as follows:
Code:
#!/bin/bash
#=============================================
# data recovery attempt for HFS/HFS+ Drives
#=============================================
echo " "$USER", input path to source Volume User Folder, ex. /Volume/drivename/Users/"
read SRC
echo " "$USER", input last name and case number."
read DST
echo "Creating Destination Directory on Volume BACKUPS."
mkdir /Volumes/BACKUPS/$DST
echo "Ditto-ing Data to Destination Directory on Volume BACKUPS."
ls -ld "$SRC"
ditto "$SRC" "/Volumes/BACKUPS/$DST"
echo "That's all she wrote..."
any time I attempt to backup directories within $SRC ex.
ditto: can't get real path for source
ditto: can't get real path for source
ditto: can't get real path for source
The reason for backing up these specific folders is that my institution is only allowed to backup Desktop, Documents, and Pictures folders (i.e. no music or movies)
so the question is now, how can I back up the Desktop, Documents, and Pictures, folder without specifing three SRC's ($SRC1, $SRC2, $SRC3)?
I tried running the code in my machine, it just works fine. Below is the code that i tried
Code:
#!/bin/bash
#=============================================
# data recovery attempt for HFS/HFS+ Drives
#=============================================
echo " "$USER", input path to source Volume User Folder, ex. /Volume/drivename/Users/"
read SRC
echo " "$USER", input last name and case number."
read DST
echo "Creating Destination Directory on Volume BACKUPS."
mkdir -p /Volumes/BACKUPS/$DST
echo "Ditto-ing Data to Destination Directory on Volume BACKUPS."
ditto $SRC/Desktop/* /Volumes/BACKUPS/$DST
ditto $SRC/Documents/* /Volumes/BACKUPS/$DST
ditto $SRC/Pictures/* /Volumes/BACKUPS/$DST
echo "That's all she wrote..."
I'm having an issue with bash read input when using a case statement.
The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here.
defaultans=8hrs
read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Hi,
I am working on a script, which requests users to enter input.
Ex: read -p "Please enter your email id:" email
I don't want users skipping this entry, this has to be mandatory.I dont want to proceed without input.
I can do a check if variable $email is empty and proceed if not.But, i... (7 Replies)
Hi All,
Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created.
/Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt
/Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Hi.
How can I create a history function? (By "read" command or so)
&
How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A)
Thanks in advance. (4 Replies)
Dear Friends,
I am looking for a shell script to merge input files into one file .. here is my idea:
1st paramter would be outfile file (all input files content)
read all input files and merge them to input param 1
ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Below is a simple script to prompt for user input while suggesting an editable default value at the prompt:
shortname=user1
read -e -i $shortname -p "Please enter the username you would like to add: " input
USERNAME="${input:-$shortname}"
Please enter the username you would like to add:... (3 Replies)
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Hi
I am new to writing script and want to use a Bash Piped while-read and read from user input.
if something happens on server.log then do while loop or if something happend on user input then do while loop.
Pseudocode something like:
tail -n 3 -f server.log | while read serverline || read... (8 Replies)
HI ,
I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script:
find <path> -ctime +200 -type f -exec ls -l {} \;
for example :
... (7 Replies)