The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Capturing output from grpck command on AIX pdtak UNIX for Dummies Questions & Answers 2 03-05-2008 02:58 PM
capturing line from script output and appending to a file wally_welder Shell Programming and Scripting 6 08-31-2007 04:03 AM
Capturing shell script command output designflaw Shell Programming and Scripting 2 03-01-2006 04:24 PM
Capturing output from C++ program GMMike UNIX for Dummies Questions & Answers 3 03-08-2005 09:04 AM
Capturing cli Program output Christopher High Level Programming 1 12-06-2001 11:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2004
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
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
  #2 (permalink)  
Old 06-01-2004
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
Unhappy

This gives me a syntax error.. but thanks
  #3 (permalink)  
Old 06-01-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
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.
  #4 (permalink)  
Old 06-01-2004
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
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.
  #5 (permalink)  
Old 06-01-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
There are several versions of sh but it's hard to tell them apart. Try this...

exec >> $sftplog
exec 2>&1
$sftpcmd $rmthost <<COMMANDS
  #6 (permalink)  
Old 06-02-2004
anarchie anarchie is offline
Registered User
  
 

Join Date: May 2004
Location: Hawaii
Posts: 37
Am I the first one to point out that the <<COMMANDS>> may be metasyntactic? Try this:

$sftpcmd $rmthost COMMANDS > $sftplog 2>&1
  #7 (permalink)  
Old 06-02-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0