- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- A strange script problem?
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
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
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-13-2004 08:56 PM
12-13-2004 08:56 PM
A strange script problem?
#!/bin/bash
WORK_DIR="/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}"
DEVICE_FILE="/mnt/back/backup_work_`date +%F`_"
DATE_TAG="work_full-back-date.tag"
BACK_LIST="/tmp/work_backlist"
if [ "$1" == "-full" ]; then
DEVICE_FILE=$DEVICE_FILE"full.tar.gz"
tar -c -f $DEVICE_FILE $WORK_DIR -z
chmod 600 $DATE_TAG
echo "`date +%F` full" > $DATE_TAG
chmod 400 $DATE_TAG
else
DEVICE_FILE=$DEVICE_FILE"inc.tar.gz"
echo $DEVICE_FILE
echo $WORK_DIR
find $WORK_DIR -newer $DATE_TAG > $BACK_LIST
tar -c -T $BACK_LIST -f $DEVICE_FILE -z
rm $BACK_LIST
fi
But it report:
tar: /mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}: Cannot stat: No such file or directory
or:
find: /mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}: No such file or directory
But if I run the tar/find command handly, it's OK? I don't know why?
Is any one can help me? thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2004 10:51 PM
12-13-2004 10:51 PM
Re: A strange script problem?
did you tried to run the script in debug mode, i.e.,
#sh -x script.name
??
Report news to us.
Regards,
Xyko
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2004 11:38 PM
12-13-2004 11:38 PM
Re: A strange script problem?
ex:
workdir='/{tmp,etc}'
EF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 02:43 AM
12-14-2004 02:43 AM
Re: A strange script problem?
according to man bash no quotes can be used with brace expansion i.e.
WORK_DIR=/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 05:06 AM
12-14-2004 05:06 AM
Re: A strange script problem?
(1) $tar cfz archive.tar.gz DIR/{file1,file2,...}
$find DIR/{file1,file2,...}
(2) $tar cfz archive.tar.gz 'DIR/{file1,file2,...}'
$find 'DIR/{file1,file2,...}'
(1) is OK, (2) can't find the files.
I use the way Michael Schulte said, problem still.
so I use #sh -x script.name to see my script,
I saw when tar/find execute, it add '' automatically, how I can strip that ?
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 05:23 AM
12-14-2004 05:23 AM
Re: A strange script problem?
the find works for me. What error do you get? There should be no '
Did you delete them from the script?
Can you post the output of bash -x script?
thanks,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 05:47 AM
12-14-2004 05:47 AM
Re: A strange script problem?
# sh -x back_work.sh
+ WORK_DIR=/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}
++ date +%F
+ DEVICE_FILE=/mnt/back/backup_work_2004-12-15_
+ DATE_TAG=work_full-back-date.tag
+ BACK_LIST=/tmp/work_backlist
+ '[' '' == -full ']'
+ DEVICE_FILE=/mnt/back/backup_work_2004-12-15_inc.tar.gz
+ echo /mnt/back/backup_work_2004-12-15_inc.tar.gz
/mnt/back/backup_work_2004-12-15_inc.tar.gz
+ echo '/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}'
/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}
+ find '/mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}' -newer work_full-back-date.tag
find: /mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}: No such file or directory
+ tar -c -T /tmp/work_backlist -f /mnt/back/backup_work_2004-12-15_inc.tar.gz -z
+ rm /tmp/work_backlist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 11:37 AM
12-14-2004 11:37 AM
Re: A strange script problem?
# touch /root/file1
# touch /root/file2
# echo /root/{file1,file2}
> /root/file1 /root/file2
# blah="/root/{file1,file2}"
# echo ${blah}
> /root/{file1,file2}
# blah='/root/{file1,file2}'
# echo ${blah}
> /root/{file1,file2}
# blah=/root/{file1,file2}
# echo ${blah}
> /root/{file1,file2}
So it would appear that expanding a {} based glob from a variable doesn't work.
Yet:
# blah='/root/file?'
# echo ${blah}
> /root/file1 /root/file2
# blah='/root/file*'
# echo ${blah}
> /root/file1 /root/file2
does work.
Limitation of the shell it seems. I can't find any reference to expansion of globs after being stored in a variable however.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 01:46 PM
12-14-2004 01:46 PM
Re: A strange script problem?
thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 11:01 PM
12-14-2004 11:01 PM
Re: A strange script problem?
try this
WORK_DIR=`eval echo /mnt/file/work/{doc03,__Download,gcc,java,js,lnx_sys_config,sh,src,sum,TeX,__webs}`
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2004 03:58 AM
12-15-2004 03:58 AM
Re: A strange script problem?
thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2004 04:06 AM
12-15-2004 04:06 AM
Re: A strange script problem?
if this helped, could you please take a moment and assign points to those who tried?
thanks,
Michael
http://forums1.itrc.hp.com/service/forums/helptips.do?#28