- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: error on script to copy files
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
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
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
тАО05-15-2013 02:54 AM
тАО05-15-2013 02:54 AM
Hi
I have the following script to copy files from one directory to another:
#!/bin/sh touch -mt 201304240000 /var/tmp/ref1 touch -mt 201305152359 /var/tmp/ref2 find /moneta_collected02/in_psl -type f \( -newer /var/tmp/ref1 -a ! -newer /var/tmp/ref2 \) > file_lst cp -pr $(< file_lst) /moneta_collected02/in_psl1/
but when I run I have the following error:
root@moneta # ./transf find: stat() error /moneta_collected02/in_psl/PSLCCN4-130106-0731-90574.gz: No such file or directory ./transf: syntax error at line 5: `(' unexpected
please can you help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 04:40 AM
тАО05-15-2013 04:40 AM
Re: error on script to copy files
>find: stat() error /moneta_collected02/in_psl/PSLCCN4-130106-0731-90574.gz: No such file or directory
It's almost as if the file as removed just as it found it. ??
You can suppress this by adding "2> /dev/null" to the end of the find.
>./transf: syntax error at line 5: `(' unexpected
You may have to check to see if file_lst is not empty before doing the cp:
if [ -s file_lst ]; then
cp -pr $(< file_lst) /moneta_collected02/in_psl1/
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 05:16 AM
тАО05-15-2013 05:16 AM
Re: error on script to copy files
Hi!
With the change suggested by Dennis, I am having the same error:
root@moneta # ./transf find: stat() error /moneta_collected02/in_psl/PSLCCN4-130106-0731-90574.gz: No such file or directory ./transf: syntax error at line 7: `(' unexpected
line 7 is :
cp -pr $(< file_lst) /moneta_collected02/in_psl1/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 05:20 AM
тАО05-15-2013 05:20 AM
Re: error on script to copy files
Have you looked inside of file_lst to see if valid filenames?
Otherwise that syntax is perfectly valid for a real shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 05:27 AM
тАО05-15-2013 05:27 AM
Re: error on script to copy files
this is what is inside:
root@moneta # head file_lst /moneta_collected02/in_psl/130304-1530-PSLCCN2-130506-0009-198970.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130506-0009-198969.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130506-2332-203175.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130506-2332-203176.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2331-185808.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2330-185806.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2331-185807.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2357-185888.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2357-185887.gz /moneta_collected02/in_psl/130304-1530-PSLCCN2-130502-2357-185886.gz root@moneta #
which is correct, unless the script does not want the directory (moneta_collected02) and the subdirectory (in_psl1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 08:25 AM
тАО05-15-2013 08:25 AM
Re: error on script to copy files
>this is what is inside: ... unless the script does not want the directory
No, that full path is fine.
What OS version are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2013 11:30 PM
тАО05-15-2013 11:30 PM
Re: error on script to copy files
Hi
It does work now after inserting the condional format (if) on HP-UX 11.31, but I try to use a similar script on a solaris 10 system and it gives me that error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:07 AM
тАО05-16-2013 12:07 AM
Re: error on script to copy files
>I try to use a similar script on a solaris 10 system and it gives me that error message.
Because Solaris isn't using a real shell for /bin/sh. You need to use a Posix or ksh.
Or you can go back to the bourne dark ages:
cp -pr `cat file_lst` ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:10 AM
тАО05-16-2013 12:10 AM
Re: error on script to copy files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:18 AM
тАО05-16-2013 12:18 AM
Re: error on script to copy files
After changing to ksh now I have a different error:
./transf[7]: /usr/bin/cp: arg list too long
But I believe if the shorten the markers :
touch -mt 201304240000 /var/tmp/ref1 touch -mt 201305152359 /var/tmp/ref2
I can solve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:19 AM
тАО05-16-2013 12:19 AM
Re: error on script to copy files
>you mean changing the #!/bin/sh by #!/bin/ksh?
Yes, that will do it.
(Of course there may be issues similar to HP-UX where shell scripts may have to use /sbin/sh so they work if /usr isn't mounted.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:20 AM
тАО05-16-2013 12:20 AM
Re: error on script to copy files
./transf[7]: /usr/bin/cp: arg list too long
But I believe if the shorten the markers :
touch -mt 201304240000 /var/tmp/ref1
touch -mt 201305152359 /var/tmp/ref2
I can solve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:28 AM
тАО05-16-2013 12:28 AM
Solution>./transf[7]: /usr/bin/cp: arg list too long
>But I believe if the shorten the markers :
But why would you want to settle? :-)
The correct solution on HP-UX and Linux would be to use: find ... -exec special-cp-script {} +
But assuming your files are large and it isn't worth trying to use xargs or write that above script, can use:
for file in $(< file_lst); do
cp -pr $file /moneta_collected02/in_psl1/
done
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 12:33 AM
тАО05-16-2013 12:33 AM
Re: error on script to copy files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2013 01:08 AM
тАО05-16-2013 01:08 AM
Re: error on script to copy files
>I have tried that but I am certain is going to work, thanks again for your help
Sure.
If you have performance issues, we can use the find/xargs solutions to invoke cp with multiple files.