- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Failed to copy file when give file name with compl...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:05 AM
тАО12-01-2010 12:05 AM
Failed to copy file when give file name with complete path
I have a small script which can create the backup file with date and time stamps. Just execute the script and give the file name its create the directory name VersnCntrl and copy the file into that directory with date and time on same location.
Now I have one issue, if I run the script and just pass the file name its work fine for me. But when I give the complete path of same file like /home/user/filename it├в s give me error. I don├в t know what is I am missing.I really appreciated if someone help me.
I am attaching the log and scripts for more details
Thanks
Khalid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:19 AM
тАО12-01-2010 12:19 AM
Re: Failed to copy file when give file name with complete path
cp: cannot create regular file `/home/tesysop/VersnCntrl//home/tesysop/schange.sh_20101201_101800': No such file or directory
Do you see the "//" (double slash)???
The script sets the path and do it too ...
/home/tesysop/VersnCntrl//home/tesysop
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:24 AM
тАО12-01-2010 12:24 AM
Re: Failed to copy file when give file name with complete path
The script sets the path and you did it again
/home/tesysop/VersnCntrl//home/tesysop
The part /home/tesysop appears now twice.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:29 AM
тАО12-01-2010 12:29 AM
Re: Failed to copy file when give file name with complete path
I want to use both option,with name and complete path.what are the possibilities.
yes i notice that double path but i don,t know how tu handle this as l am not tu good in scripting :-(
Thanks
Khalid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:36 AM
тАО12-01-2010 12:36 AM
Re: Failed to copy file when give file name with complete path
Options are
- modify your script to accept the full path
- don't use the script, do it manually
- don't use the full path
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 12:52 AM
тАО12-01-2010 12:52 AM
Re: Failed to copy file when give file name with complete path
So don't do anything and use the script as intended (without full path).
Ask the author!
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 01:44 AM
тАО12-01-2010 01:44 AM
Re: Failed to copy file when give file name with complete path
The command "basename" takes a pathname as input and gives only the last component of the pathname as output. The pathname is not required to actually exist.
Examples:
$ basename /home/tesysop/schange.sh
schange.sh
$ basename /home/tesysop
tesysop
$ basename schange.sh
schange.sh
The command "dirname" takes a pathname as input and gives only the directory path part as output. If the input does not contain a directory path, the command outputs "." (=current directory). As with "basename", the input pathname is not required to actually exist.
Examples:
$ dirname /home/tesysop/schange.sh
/home/tesysop
$ dirname /home/tesysop
/home
$ dirname schange.sh
.
In the script, the first argument is simply stored in the variable "ipfilename":
ipfilename=$1
Instead, you could split it into components like this:
ipfile=$(basename $1)
ipdir=$(dirname $1)
Now, if you want to use the original pathname (as a source for a copy operation, or for testing its existence), you can replace "$ipfilename" with "$ipdir/$ipfile".
If $1 is a simple filename, for example "schange.sh", then "$ipdir/$ipfile" becomes "./schange.sh" when variables are expanded... and that's a valid pathname to a file located in the current directory, so it works.
On the parts of the script where you need just the filename (e.g. when you're using it to refer to the destination file), you can replace "$ipfilename" with just "$ipfile".
This would cause the script to create all backup copies in the $VCDIR directory - it would never attempt to create or use any subdirectories under $VCDIR. Is this what you wanted?
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 01:50 AM
тАО12-01-2010 01:50 AM
Re: Failed to copy file when give file name with complete path
I just add one more step first copy then move into target directory and its seem its working fine for me.
the changes are below.
ipfilename=$1
if [ -f "$ipfilename" ];
then
if [ -d "$VCDIR" ]; then
cp -p "$ipfilename" "$ipfilename"_$ydt
mv "$ipfilename"_* "$VCDIR"/
chmod -x "$VCDIR"/"$ipfilename"
echo "$ydt :: Version Controlled Successfull for $ipfilename " >>$CLOG
echo "Version Controlled Successfull "
else
Thanks MK but this changes are work fine for me thats why i did not follow your suggestion but Thanks.
Khalid