- 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
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
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