[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
|
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
8973.0. "CRON does not perform command substitution after > symbol" by NETRIX::"[email protected]" (R.J. Riha") Wed Feb 26 1997 11:06
Versions tested: V3.2G, V4.0B
Have a customer who is trying to perform command line substitution from within
his crontab file:
0 * * * * /usr/users/ao/lnk/lnk.csh > new`date +%a`.log
instead of creating an output file called "newTue.log", it creates "new"
If you do this from the command line (bourne shell), it works:
$ /usr/users/ao/lnk/lnk.csh > new`date +%a`.log
$ ls *.log
newTue.log
It also appears that if the command substitution is performed before the
pipe ">" symbol, it works:
0 * * * * echo The hour is `date`. >/dev/console
Prints:
The hour is Tue Feb 25 14:00:00 EST 1997 V4.0b system.
According to the Man Page, I see no reason for it not to work on either
side of the pipe symbol:
"Command Substitution
To capture the output of any command as an argument to another command,
place that command line within ` ` (grave accents). This concept is known
as command substitution. The shell first executes the command or commands
enclosed within the grave accents, and then replaces the whole expression,
grave accents and all, with their output. This feature is often used in
assignment statements:
today=`date`
This statement assigns the string representing the current date to the
today variable. The following assignment saves, in the files variable, the
number of files in the current directory:
files=`ls | wc -l`
You perform command substitution on any command that writes to standard
output by enclosing that command in grave accents. You can nest command
substitutions by preceding each of the inside sets of grave accents with a
\ (backslash):
logmsg=`echo Your login directory is \`pwd\``"
Thanks,
RJ
[Posted by WWW Notes gateway]
T.R | Title | User | Personal Name | Date | Lines |
---|
8973.1 | Try absolute pathname to date | NETRIX::"[email protected]" | Brian Haley | Wed Feb 26 1997 15:34 | 13 |
| Hi,
Instead of:
new`date +%a`.log
try:
new`/usr/bin/date +%a`.log
Cron might not have date in his path.
-Brian
[Posted by WWW Notes gateway]
|
8973.2 | Then why does it work before the pipe symbol | NETRIX::"[email protected]" | R.J. Riha "Providing 2 cents worth at 50% off!" | Thu Feb 27 1997 15:51 | 13 |
| Re. 1
If cron couldn't find the path to "date", then substituting it into
the command before the pipe symbol should fail also, right? That is
not the case. It only fails after the > symbol.
FYI, I did try your suggestion anyway, the behavior (as expected) did
not change.
Thanks
RJ
[Posted by WWW Notes gateway]
|
8973.3 | \ before each % | NETRIX::"[email protected]" | Lucius Schmid UNIX Support Switzerland | Tue Mar 25 1997 04:37 | 9 |
| Hi
You need a \ before each % symbol!
0 * * * * /usr/users/ao/lnk/lnk.csh > new`date +\%a`.log
Regards
Lucius
[Posted by WWW Notes gateway]
|