how to copy a file to a directory ,where file and dir are sent as args to a function?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to copy a file to a directory ,where file and dir are sent as args to a function?
# 1  
Old 06-08-2008
how to copy a file to a directory ,where file and dir are sent as args to a function?

Hi all,

I wanted to know how i can copy a file to a directory and then verify if that file is completely copied or not?
Now the issues here is that the dir and the source file are to be sent as arguments to a function( this function should actually copy the files to a dir, then check if its completely copied)

I dont want to use the

if [ -e <filename>]
option then figure out if the file exists in the dir or not....
Reason being i am giving a progress bar that actually calculates the % of completion....
I have written scripts that do the job ,but a pre-requisite is that a file already needs to exist in the dir, then to this file i can copy my source file.

But my idea is to have no files in the targeted dir ,and when the cp is done the source file should exist in the destination dir!!!!

please help!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Switching between directories and mkdir/copy dir/file

I was trying to copy the files inside the path /home/user/check/Q1/dir/folder1/expected/n/a1.out1 and a1.out2 and a1.out3 to /home/user/check/Q2/dir/folder1/expected/n/ if n directory is not present at Q2/dir/folder1/expected/ then directory should be created first. And, script follow the... (5 Replies)
Discussion started by: Mannu2525
5 Replies

2. UNIX for Dummies Questions & Answers

Issues in Csv file transfer copy from one dir to another

Hi Unix community, I got this code from you guys and I tried to modify it to use for my csv dir transfer basically i want the .csv file to copy itself and populate it to the archive dir. #!/bin/ksh dir1="/home/pumela/unixtestprod" cd "$dir1" echo "code is running" for srcd in... (13 Replies)
Discussion started by: phumaree
13 Replies

3. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

4. Programming

how to copy file to a directory

Hello, I've been spending a lot of hours trying to imitate cp copying a file to a directory. cp I just can't seem to write to a specified directory, it only creates a copy on the current directory. any hints/tips will help! Thanks! here's the code i've been trying to manipulate: ... (1 Reply)
Discussion started by: l flipboi l
1 Replies

5. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

6. UNIX for Dummies Questions & Answers

How to copy a file to a directory?

Hello all, I've been researching this problem for days, and have gotten no luck . =/ How do you copy a file to another directory without being in the same directory as the file? So, for example, say I wanted to copy the file 'my.txt' that is in the directory ' /export/hom0/user/asdf ' to the... (9 Replies)
Discussion started by: kvnqiu
9 Replies

7. Shell Programming and Scripting

Copy Files to Dir and Check If File Exists

Hi everyone. I am trying to write a bash script that will copy files from one directory to another but I need to be able to check the directory that I'm copying the files to and see if the file already exists. If it does I need to add a number at the end of the copied file. Thanks for your help. (3 Replies)
Discussion started by: snag49ers
3 Replies

8. UNIX for Dummies Questions & Answers

Copy dir/file from one place to another.

Hello all. I'm not getting the hang of Paths. I have a dir w/files that I want to copy to another dir. Right now I am in the "source" directory. I want to copy it to Ch7. "cp -r source Ch7". Ch7 was already created. 1st msg.: cannot stat `source`: No such file or dir. I typed pwd & got... (3 Replies)
Discussion started by: Ccccc
3 Replies

9. UNIX for Dummies Questions & Answers

Copying dir (and sub dir) file names from ftp server to txt file in diff server

Hey all, i want to copy only the file names from an ftp server (directory and all sub directory) to a text file in another server (non ftp), i.e. i want to recursively move through directories and copy only the names to a text file. any help is appreciated...thank you in advance (1 Reply)
Discussion started by: deking
1 Replies

10. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies
Login or Register to Ask a Question
virt-copy-in(1) 					      Virtualization Support						   virt-copy-in(1)

NAME
virt-copy-in - Copy files and directories into a virtual machine disk image. SYNOPSIS
virt-copy-in -a disk.img file|dir [file|dir ...] /destination virt-copy-in -d domain file|dir [file|dir ...] /destination WARNING
Using "virt-copy-in" on live virtual machines can be dangerous, potentially causing disk corruption. The virtual machine must be shut down before you use this command. DESCRIPTION
"virt-copy-in" copies files and directories from the local disk into a virtual machine disk image or named libvirt domain. You can give one of more filenames and directories on the command line. Directories are copied in recursively. The final parameter must be the destination directory in the disk image which must be an absolute path starting with a "/" character. EXAMPLES
Update "/etc/resolv.conf" in a guest: virt-copy-in -d MyGuest resolv.conf /etc Upload a home directory to a guest: virt-copy-in -d MyGuest skel /home JUST A SHELL SCRIPT WRAPPER AROUND GUESTFISH
This command is just a simple shell script wrapper around the guestfish(1) "copy-in" command. For anything more complex than a trivial copy, you are probably better off using guestfish directly. OPTIONS
Since the shell script just passes options straight to guestfish, read guestfish(1) to see the full list of options. SEE ALSO
guestfish(1), virt-cat(1), virt-copy-out(1), virt-edit(1), virt-tar-in(1), virt-tar-out(1), http://libguestfs.org/. AUTHORS
Richard W.M. Jones ("rjones at redhat dot com") COPYRIGHT
Copyright (C) 2011-2012 Red Hat Inc. LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. BUGS
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools When reporting a bug, please supply: o The version of libguestfs. o Where you got libguestfs (eg. which Linux distro, compiled from source, etc) o Describe the bug accurately and give a way to reproduce it. o Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report. libguestfs-1.22.6 2013-08-24 virt-copy-in(1)