Sponsored Content
Operating Systems OS X (Apple) using variables when copying files Post 302636637 by hungryd on Monday 7th of May 2012 06:27:08 PM
Old 05-07-2012
using variables when copying files

smaller sample from a larger script: i'm simply trying to copy files from one desktop directory on a mac to another using variables. when i first test the logic of the script without variables, everything works and the copy is effective.

but i'm unable to call the same copy by passing a variable. script runs as root, FYI. much obliged if you can weigh in. hoping it's just a syntax error that i'm missing.

Code:
#!/bin/sh

oldWS="/Volumes/Lion\ BaseOS/Users/workstation"
newWS="/Users/workstation"

echo "Migrating any old Desktop files from $oldWS/Desktop..."
cp "${oldWS}/Desktop/*" "${newWS}/Desktop"
if [ $? != 0 ]; then
	echo "There was a problem migrating files from $oldWS/Desktop, PLEASE INVESTIGATE."
else
	echo "Files from $oldWS/Desktop have been moved to the new Mac."
fi

exit 0

i'm assuming that i've got a syntax error here but i can't see where. i use similar syntax in other scripts all the time...

thanks for whatever insight you might have to share.

david

---------- Post updated at 03:27 PM ---------- Previous update was at 03:20 PM ----------

forgot to mention the error i'm getting:

Code:
cp: /Volumes/Lion\ BaseOS/Users/workstation/Desktop/*: No such file or directory

which is odd as:
a) the directory does exist
b) when i run the cp manually and without variables, it's. just. fine.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies

2. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

3. Shell Programming and Scripting

copying files

hi I want to copy all files from the current directory and move to .archive file. Moreover,I want to add .bak to each file name, that will be copied. How can I do that? (4 Replies)
Discussion started by: tjay83
4 Replies

4. Solaris

Copying Files

Hi, I understand that to copy files across server, the feasible way will be using scp command. Am I right? What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well? ... (3 Replies)
Discussion started by: user50210
3 Replies

5. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

6. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

7. Shell Programming and Scripting

Help needed in perl; moving or copying the variables

Hi All, I have a perl script blc.pl; i have five variables a,b,c,d and e in this script. Now I want to copy the values of these variables into a data file,say abc.dat.. Can anybody please tell me how to do this? Any help is appreciated.. Thanks in advance (2 Replies)
Discussion started by: puneetkanchi
2 Replies

8. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

9. Shell Programming and Scripting

Copying files

All, I need to grab and rename common files from several unique directory structures. For example, the directory structures looks like: /unique_dir/common/common/common/person_name_dir/common_file.txt There are over 90,000 of these text files that I'd like to put in a single directory as... (5 Replies)
Discussion started by: hburnswell
5 Replies

10. Shell Programming and Scripting

Copying files

I'm trying to do this exact same thing, so far I have created this to move files i've named my script CP.sh #!/bin/bash cd /root/my-documents/NewDir/ for f in *.doc do cp -v $f root/my-documents/NewDir $f{%.doc} done When i go to run this in the console i type, bin/sh/ CP.sh but it... (7 Replies)
Discussion started by: MKTM_93_SIMP
7 Replies
gnome-control-center(1) 					   User Commands					   gnome-control-center(1)

NAME
gnome-control-center, gnome-desktop-prefs - configure desktop preferences SYNOPSIS
gnome-control-center [gnome-std-options] [--noshell] DESCRIPTION
Desktop Preferences allows you to configure the GNOME desktop. If Nautilus is running, gnome-control-center will open up a new window and display all your preference tools. If Nautilus is not running, gnome-control-center will display a simple interface allowing you to select the preference tool to run. There are 3 categories of preference tools: Basic, Advanced, and Accessibility. Double-click on the tool that you require and the dialog for the tool will be displayed. OPTIONS
The following options are supported: --noshell Do not display the Desktop Preferences in Nautilus. This is not a supported interface. gnome-std-optionStandard options available for use with most GNOME applications. See gnome-std-options(5). EXAMPLES
Example 1: Launching Desktop Preferences example% gnome-control-center EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gnome-control-cExecutable for Desktop Preferences interface ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+------------------------------+ |Availability |SUNWgnome-desktop-preferences | +-----------------------------+------------------------------+ |Interface stability |External | +-----------------------------+------------------------------+ SEE ALSO
Preference Tools Manual Latest version of the GNOME Desktop User Guide for your platform. gnome-background-properties(1), gnome-font-properties(1), gnome-keyboard-properties(1), gnome-keybinding-properties(1), gnome-ui-proper- ties(1), gnome-mouse-properties(1), gnome-network-preferences(1), gnome-sound-properties(1), gnome-theme-properties(1), metacity-proper- ties(1), gnome-accessibility-keyboard-properties(1), cddb-slave2-properties(1), gnome-file-types-properties(1), gnome-panel-preferences(1), gnome-default-applications-properties(1), gnome-session-properties(1), gnome-std-options(5) NOTES
Written by Glynn Foster, Sun Microsystems Inc., 2003. SunOS 5.10 2 Oct 2003 gnome-control-center(1)
All times are GMT -4. The time now is 09:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy