help-ksh as cronjob, line too long


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help-ksh as cronjob, line too long
# 1  
Old 12-13-2011
help-ksh as cronjob, line too long

Hello all,

i need to get a script running which checks for powersupply problems of attached storages. I was faced with problems running this script in a terminal session, obviously the procued outupt is to long, but the problem could be solved with 'stty columns 120'. but I can't use this command when the script is executed by cron.
example :
Code:
stty columns 120      #no effect in cron
export TERM=vt220     #no effect in cron
export COLUMNS=120    #no effect in cron
$LSSCS list -t Problem -f PowerSupply event >> $LOGFILE1
echo "`$LSSCS list -t Problem -f PowerSupply event`" | while read line
do
        echo "Line : $LINENO = $line"
        echo $line >> $LOGFILE2
done

this is what i expect, one line :
Code:
Line : 12 = 2011-07-15 10:20:27 404869 psppnode102-ST6140_2-1247769116 (StorageTek 6140) Tray.85.PowerSupply.A Problem

this is what i get when the script is executed as cronjob, the content of LOGFILE1/2 is similar corrupt :
Code:
Line : 12 = 2011-07-15        404869 psppnode102-ST6140_ Tray.85.PowerSupp Problem
Line : 12 = 10:20:27                 2-1247769116      ly.A

does anybody know how do handle this problem...any idea would be helpful
thanks in advance...



Moderator's Comments:
Mod Comment How to use code tags

Last edited by methyl; 12-13-2011 at 07:21 AM.. Reason: Please use code tags for code and data samples, thank you. Removed funny font.
# 2  
Old 12-13-2011
That is weird!... May it is coupling the stderr and stdout?...
Try doing this...
Code:
$LSSCS list -t Problem -f PowerSupply event >> $LOGFILE1 2>&1

--ahamed
# 3  
Old 12-13-2011
Also make sure that you are running the Shell you think you are. In SunOS the default Shell in cron is the old Bourne Shell.
For example:
Code:
#!/usr/bin/ksh

For diagnostics, let's find out what the program is outputting in case it is outputting control codes or using more than one channel.

Code:
LOGFILE4=/tmp/mylog4
LOGFILE5=/tmp/mylog5
$LSSCS list -t Problem -f PowerSupply event 2>>$LOGFILE4 1>>$LOGFILE5
sed -n l $LOGFILE4
sed -n l $LOGFILE3

# 4  
Old 12-13-2011
Hello...
I tried this as cronjob :

Code:
$LSSCS list -t Problem -f PowerSupply event >> $LOGFILE1 2>&1
echo "`$LSSCS list -t Problem -f PowerSupply event`" | while read line
do
        echo $line >> $LOGFILE2 2>&1
done
$LSSCS list -t Problem -f PowerSupply event 2>> $LOGFILE4 1>>$LOGFILE5
sed -n l $LOGFILE4
sed -n l $LOGFILE5

$LOGFILE1 :
Code:
Date              Id     Device            Component         Type
----------------- ------ ----------------- ----------------- -----------------
2011-07-15        404869 blnace302-ST6140_ Tray.85.PowerSupp Problem
10:20:27                 2-1247769116      ly.A
                         (StorageTek 6140)
...

$LOGFILE2 :
Code:
Date Id Device Component Type
----------------- ------ ----------------- ----------------- -----------------
2011-07-15 404869 blnace302-ST6140_ Tray.85.PowerSupp Problem
10:20:27 2-1247769116 ly.A
(StorageTek 6140)
...


$LOGFILE4: empty
$LOGFILE5:

Code:
Date              Id     Device            Component         Type
----------------- ------ ----------------- ----------------- -----------------
2011-07-15        404869 blnace302-ST6140_ Tray.85.PowerSupp Problem
10:20:27                 2-1247769116      ly.A
                         (StorageTek 6140)
...

mail reply from cron :
Code:
Date              Id     Device            Component         Type      \

----------------- ------ ----------------- ----------------- ----------\
-------
2011-07-15        404869 blnace302-ST6140_ Tray.85.PowerSupp Problem   \

10:20:27                 2-1247769116      ly.A                        \

                         (StorageTek 6140)                             \

2011-07-15        404872 blnace302-ST6140_ Tray.85.PowerSupp ProblemCle\
arEvent
10:25:27                 2-1247769116      ly.A                        \

                         (StorageTek 6140)                             \
...

# 5  
Old 12-13-2011
It is not truncating, it is formatted! And it is done by $LSSCS command...

--ahamed
# 6  
Old 12-13-2011
Just for completeness, I'd still be interested in the output from this command (designed to make control codes visible):
Code:
sed -n l $LOGFILE5

Just in case some of the white space is tabs or the file contains screen or printer control codes.


By the way, the squashed effect in $LOGFILE2 is caused by the absence of double quotes on this line:
Code:
echo "$line" >> $LOGFILE2


Observation: The heading second line is exactly 80 characters wide. Your original problem is still there.

Last edited by methyl; 12-13-2011 at 08:23 AM..
# 7  
Old 12-13-2011
hello methyl,

for comparison :
Code:
2011-07-15 10:20:27 404869 psppnode102-ST6140_2-1247769116 (StorageTek 6140) Tray.85.PowerSupply.A Problem


the complete output :
Code:
root@blnace302> sed -n l /tmp/mylog5
Date              Id     Device            Component         Type      \

----------------- ------ ----------------- ----------------- ----------\
-------
2011-07-15        404869 blnace302-ST6140_ Tray.85.PowerSupp Problem   \

10:20:27                 2-1247769116      ly.A                        \

                         (StorageTek 6140)                             \

2011-07-15        404872 blnace302-ST6140_ Tray.85.PowerSupp ProblemCle\
arEvent
10:25:27                 2-1247769116      ly.A                        \

                         (StorageTek 6140)                             \

2011-10-25        463900 blnace302-ST6140_ Tray.85.PowerSupp Problem   \

12:24:13                 1-1247766974      ly.B                        \

                         (StorageTek 6140)                             \

2011-10-25        463913 blnace302-ST6140_ Tray.85.PowerSupp ProblemCle\
arEvent
12:54:13                 1-1247766974      ly.B                        \

                         (StorageTek 6140)                             \

root@blnace302>

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script throwing arg list too long for mv cp wc - everything

i have a ksh script which internally calls another ksh script. this inner script has simple commands like shown in the code window. In the script im trying to do a mv - it fails with arg list too long. then i try to perform cp and cat - and both are failing with similar error. :wall: How is... (4 Replies)
Discussion started by: nyc68
4 Replies

2. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

3. AIX

aix:ksh: /usr/bin/rm: 0403-027 The parameter list is too long.

Hi, I am getting the below error message When i am trying to delete the files from the directory.Could you please guide me? rm *.aud ksh: /usr/bin/rm: 0403-027 The parameter list is too long. and find /oracle/admin/testP/adump/*.aud -mtime +5 -exec rm {} \; ksh: /usr/bin/find:... (3 Replies)
Discussion started by: nokiae63
3 Replies

4. UNIX for Dummies Questions & Answers

vi : Line too Long Error

Hi ! I am woking on Solaris 5.10 and face a problem sometimes when i try to open files in the vi editor . Sometime when the file is big i am not able to view the file in vi and i get the error like I guess vi have some line size setting and if the lines are ,longer than that... (4 Replies)
Discussion started by: Paarth
4 Replies

5. UNIX for Dummies Questions & Answers

grep long line

I am trying to get the count of a word from an xml using the below command grep "search word" -c test.xml The result is only 1, because my xml contains only one line (hule line- several thousand characters). I guess grep command will process for only 128 characters for each line. ... (7 Replies)
Discussion started by: venky23
7 Replies

6. UNIX for Advanced & Expert Users

help on ksh and sql..getting error as is too long. maximum size is 240 characters."

Hi, In my script i am executing sql file and there are some variables in SQL files which are assigned at run time. one of the variable value is having more than 240 characters and at time of execution its getting failed with error as "is too long. maximum size is 240 characters." ... (1 Reply)
Discussion started by: pooga17
1 Replies

7. UNIX for Dummies Questions & Answers

vi.....line too long

I'm getting a "line too long" error when I try to vi a particular file. I really just need to view the contents as I don't have to change anything. Any suggestions?? I already tried to cat but it didnt work........:( (7 Replies)
Discussion started by: shorty
7 Replies

8. Shell Programming and Scripting

search a long line

Hey all, I need to retrieve something from a line, say <TEST><A>123</A><B>456</B><ID>1111</ID><C>789</C><D>000</D></TEST><TEST><A>123</A><B>456</B><ID>2222</ID><C>789</C><D>000</D></TEST> I need to match <ID>111</ID>, so I want to retrieve <ID>1111</ID><C>789</C><D>000</D></TEST> is... (14 Replies)
Discussion started by: mpang_
14 Replies

9. UNIX for Dummies Questions & Answers

ksh: /usr/bin/ls: arg list too long

I am using IBM AIX unix version 4.3.3.0. In a directory there are many files with different patterns. When I am trying to execute the command, ls -l with the file pattern, which have fewer files it gives the desired result. However when I am trying to execute the same command for file pattern,... (2 Replies)
Discussion started by: jitindrabappa
2 Replies

10. Shell Programming and Scripting

ksh: /bin/grep: arg list too long

when i run the command below in a directory which contains too many files i got the error: ksh: /bin/grep: arg list too long ls|grep AA*B* how can i handle this problem? (5 Replies)
Discussion started by: gfhgfnhhn
5 Replies
Login or Register to Ask a Question