BASH - read use a path as input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting BASH - read use a path as input
Prev   Next
# 1  
Old 04-30-2010
BASH - read use a path as input

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."

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash read input in case statement not working as expected

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)
Discussion started by: woodson2
5 Replies

2. Shell Programming and Scripting

Read input from Keyboard, do not proceed if no input

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)
Discussion started by: aravindadla
7 Replies

3. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

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)
Discussion started by: karthikgv417
6 Replies

4. Shell Programming and Scripting

[Bash] Read History function & Read Arrowkeys

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)
Discussion started by: sinnlosername
4 Replies

5. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

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)
Discussion started by: hyd1234
4 Replies

6. Shell Programming and Scripting

BASH - read does not wait for user input in some circumstances

Hello. I am running 2 scripts : script_1 and script_2 These scripts are run as root Script 2 contains : #!/bin/bash # # ~/bin/script_2 # E_BAD_PARAM=115 # date2stamp () { date --date "$1" +%Y-%m-%d___%H:%M:%S } # USER_NAME=$1 NB_PARAM=$# PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies

7. Shell Programming and Scripting

Using read to prompt for editable user input in Bash 3

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)
Discussion started by: woodson2
3 Replies

8. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

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)
Discussion started by: *ShadowCat*
3 Replies

9. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

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)
Discussion started by: MyMorris
8 Replies

10. UNIX for Advanced & Expert Users

Help-prompt for path and take this as input in find command

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)
Discussion started by: bsandeep_80
7 Replies
Login or Register to Ask a Question
HCOPY(1)						      General Commands Manual							  HCOPY(1)

NAME
hcopy - copy files from or to an HFS volume SYNOPSIS
hcopy [-m|-b|-t|-r|-a] source-path [...] target-path DESCRIPTION
hcopy transfers files from an HFS volume to UNIX or vice versa. The named source files are copied to the named destination target, which must be a directory if multiple files are to be copied. Copies are performed using a translation mode, which must be one of: -m MacBinary II: A popular format for binary file transfer. Both forks of the Macintosh file are preserved. This is the recommended mode for transferring arbitrary Macintosh files. -b BinHex: An alternative format for ASCII file transfer. Both forks of the Macintosh file are preserved. -t Text: Performs end-of-line translation. Only the data fork of the Macintosh file is copied. -r Raw Data: Performs no translation. Only the data fork of the Macintosh file is copied. -a Automatic: A mode will be chosen automatically for each file based on a set of predefined heuristics. If no mode is specified, -a is assumed. If a UNIX source pathname is specified as a single dash (-), hcopy will copy from standard input to the HFS destination. Likewise, a single dash used as a UNIX destination pathname will cause hcopy to copy the HFS source to standard output. NOTES
Copied files may have their filenames altered during translation. For example, an appropriate file extension may be added or removed, and certain other characters may also be transliterated. The destination target must not be ambiguous; that is, it must be obvious whether the target is on the UNIX filesystem or on an HFS volume. As a rule, HFS targets must contain at least one colon (:), usually as the beginning of a relative pathname or by itself to represent the current working directory. To make a UNIX target unambiguous, either use an absolute pathname or precede a relative pathname with a dot and slash (./). SEE ALSO
hfsutils(1), hls(1), hattrib(1) AUTHOR
Robert Leslie <rob@mars.org> HFSUTILS
13-Jan-1997 HCOPY(1)