The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to cp files to dir,using routine? wrapster UNIX for Advanced & Expert Users 1 05-21-2008 02:18 PM
sub routine call sekar sundaram Shell Programming and Scripting 2 11-10-2005 08:30 PM
Need basic disk copy routine for AIX 3 tekmeister AIX 0 09-29-2005 11:29 PM
Routine Task being a Solaris Administrator Far UNIX for Dummies Questions & Answers 1 02-09-2005 10:19 AM
Entry Points Routine S.P.Prasad High Level Programming 9 10-21-2002 11:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
how to cp files to dir,using routine?

hi all,

I wanted to know how we can copy files to dirs, through a routine and when the file and the dir are specified as parameters for that routine and explicitly called?

Eg: suppose i want to copy file1 to /tmp then

myproc()
{
.
.
}

myproc /path/file1 /tmp/
These parameters when passed to the myproc() ,file1 should be copied to /tmp

May i know how it can be done?
  #2 (permalink)  
Old 05-21-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Code:
myproc()
{
  cp $1 $2
}

myproc /path/file1 /tmp/
  #3 (permalink)  
Old 05-21-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
I have tried that, but its not working....
Says something like this, "file1 : no such file or directory"

is there any other way?

Thanks
  #4 (permalink)  
Old 05-21-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Quote:
Originally Posted by wrapster View Post
I have tried that, but its not working....
Says something like this, "file1 : no such file or directory"
If the file don't exist that's normal.
  #5 (permalink)  
Old 05-21-2008
wrapster wrapster is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 193
that is correct, the file doesnt exist....
However why is it that we cannot emulate the cp command ,from the routine?

How is it that when using the cp cmd it works fine,but only when parameters are passed ,and expected a cp,this thing fails???

Secondly, this function is to be included in a boot script that actually copies a few files onto /tmp....
Since this was not working unless a file was specified as the "dest" i created a dummy file in tmp(having the same name) then used a suitable () to cp from src to dest, but i get some memory issues,.....
What could be the problem?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0