- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- ksh script fails if runs from another dir, (for fi...
Operating System - Linux
1753971
Members
8618
Online
108811
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО02-04-2010 02:43 PM
тАО02-04-2010 02:43 PM
Hello, all
Hope you can easely point me what it wrong witmy setup, I created .ksh script with command and I can't run it from one location and can run OK from another dir. what can be wrong ??
Tried absolutely everything, doen's matter what user, do it from command line with args.
if fails get this:
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
command itself is:
find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
I"ve played with qoutes around DIRR, no result either. I attached all info in .txt attached.
Tx big to all
J
##################### my script:
#!/usr/bin/ksh
DIRR=/$1
MASK=*.$2
TERM=$3
echo " f11 gymscripts: $1 2:$2 3:$3 "
echo " DIRR= $DIRR term=$TERM for files with $MASK"
echo " .... find coming "
#ls -l $DIRR/$MASK
find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
echo "_______________ end"
######################################
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
_______________ end
Hope you can easely point me what it wrong witmy setup, I created .ksh script with
Tried absolutely everything, doen's matter what user, do it from command line with args.
if fails get this:
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
command itself is:
find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
I"ve played with qoutes around DIRR, no result either. I attached all info in .txt attached.
Tx big to all
J
##################### my script:
#!/usr/bin/ksh
DIRR=/$1
MASK=*.$2
TERM=$3
echo " f11 gymscripts: $1 2:$2 3:$3 "
echo " DIRR= $DIRR term=$TERM for files with $MASK"
echo " .... find coming "
#ls -l $DIRR/$MASK
find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
echo "_______________ end"
######################################
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
_______________ end
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 03:11 PM
тАО02-04-2010 03:11 PM
Re: ksh script fails if runs from another dir, (for find:)
Shalom,
If your script sets the PATH environment to include where find command actually is, this kind of inconsistency can be avoided.
There also appears to be a possible problem with one of the variables on the find line, $DIRR $MASK or $TERM being wrong.
Also remember that / is interpreted differently by the shell and may need to be escaped.
SEP
If your script sets the PATH environment to include where find command actually is, this kind of inconsistency can be avoided.
There also appears to be a possible problem with one of the variables on the find line, $DIRR $MASK or $TERM being wrong.
Also remember that / is interpreted differently by the shell and may need to be escaped.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2010 03:58 PM
тАО02-04-2010 03:58 PM
Solution
Hi:
If you use wildcard characters in 'find' commands you need to quote the argument containing them so that the shell doesn't interpret them. Rather, you want them passed to 'find' for it to interpret.
In your case, most notably the '$MASK' variable contains a "*" character. Depending on what's in or not it your starting directory this can cause different behavior. To see what is really happending, change to your various directories and simply do:
# echo ${MASK}
For that matter, do :
# echo *
Instead of doing:
# find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
...do:
# find $DIRR -name "$MASK" -mtime +$TERM -exec ls {} \;
As an aside, it is also better (faster) to do:
# find $DIRR -name "$MASK" -mtime +$TERM -exec ls {} +
...which causes multiple arguments to be collected for each process spawned by '-exec'. Thus, in this case, instead of running 'ls' for *each* object found, you run 'ls' for multiple arguments at a time.
You might also want to limit your output to only files:
# find $DIRR -type f -name "$MASK" -mtime +$TERM -exec ls {} +
Regards!
...JRF...
If you use wildcard characters in 'find' commands you need to quote the argument containing them so that the shell doesn't interpret them. Rather, you want them passed to 'find' for it to interpret.
In your case, most notably the '$MASK' variable contains a "*" character. Depending on what's in or not it your starting directory this can cause different behavior. To see what is really happending, change to your various directories and simply do:
# echo ${MASK}
For that matter, do :
# echo *
Instead of doing:
# find $DIRR -name $MASK -mtime +$TERM -exec ls {} \;
...do:
# find $DIRR -name "$MASK" -mtime +$TERM -exec ls {} \;
As an aside, it is also better (faster) to do:
# find $DIRR -name "$MASK" -mtime +$TERM -exec ls {} +
...which causes multiple arguments to be collected for each process spawned by '-exec'. Thus, in this case, instead of running 'ls' for *each* object found, you run 'ls' for multiple arguments at a time.
You might also want to limit your output to only files:
# find $DIRR -type f -name "$MASK" -mtime +$TERM -exec ls {} +
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP