capturing output in script

I have the following line in my script:
$sftpcmd $rmthost <<COMMANDS>> $sftplog 2>&1

For some reason this is not capturing the errors from sftp, they go to the file attached to the cron entry
ie
mm hh dd MM * /myscript > cron.out

any idea why?

digital unix 4.0d

This gives me a syntax error.. but thanks

You don't say what shell you are using. With ksh, the only way I think this would happen would be having $sftplog expand to nothing at all.

So put a line in..

echo sftplog = $sftplog

and see what it is set to.

Sorry. this is sh.

I have a variable $sftplog setup that goes to a file

sftplog=$Home/sftplog

I have to be able to verify that the transfer was successful so I am using an ls -l command into the sftplog to be able to analyze what is on the receving server. Since I can't find anyway to get the sftp command to give me a completion message.

the ls -l comes back into the sftplog ok... but the errors don't.

There are several versions of sh but it's hard to tell them apart. Try this...

exec >> $sftplog
exec 2>&1
$sftpcmd $rmthost <<COMMANDS

Am I the first one to point out that the <<COMMANDS>> may be metasyntactic? Try this:

$sftpcmd $rmthost COMMANDS > $sftplog 2>&1

MizzGail, anarchie is suggesting that the string:
<<COMMANDS>>
does not actually appear in your shell script. Shells use << to start a here-is document and it is common to make the sentinel an all-caps word. And shells use >> to redirect in append mode. So whether or not you really are using << and >> in the command is crucial. Please confirm the syntax of the command.