script line not working properly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script line not working properly
# 1  
Old 01-29-2010
script line not working properly

Hi ,
I am using the below command in script. $_IDLETIME is returning value if i execute the script manually.

Code:
sar > $_LOCATION/sar.txt

_IDLETIME=`tail -2 $_LOCATION/sar.txt | head -1 | tr -s ' ' ' ' | cut -d ' ' -f8 | cut -d '.' -f1`;

if [ $_IDLETIME -gt 60 ]

But it s not returning any value if it put the script in cron..

Any soluting for this...


Thanks,
Ahamed.

Last edited by Franklin52; 01-29-2010 at 03:51 PM.. Reason: Please use code tags!!
# 2  
Old 01-29-2010
The usual problem with running things in cron is paths. You don't get all your usual PATH values set by default so it can't find things it can when running inside your shell. Try calling sar with its absolute path, /usr/sbin/sar or what have you.
# 3  
Old 01-29-2010
Hi,
I am able to get the sar report. from the sar.txt i not able to get the value after using tail,cut etc command. I am able to see sar report in sar.txt

Ahamed.
# 4  
Old 01-29-2010
Quote:
Originally Posted by ahamed
Hi ,
I am using the below command in script. $_IDLETIME is returning value if i execute the script manually.

Code:
sar > $_LOCATION/sar.txt

_IDLETIME=`tail -2 $_LOCATION/sar.txt | head -1 | tr -s ' ' ' ' | cut -d ' ' -f8 | cut -d '.' -f1`;

if [ $_IDLETIME -gt 60 ]

But it s not returning any value if it put the script in cron..

Have you tried printing its value to see what has been assigned to it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File count script not working properly

Hi Experts, I have this script to count the number of files based on prefix and suffix values. #!/bin/ksh file_date=$1 prefix=$2 suffix=$3 file_count=$(ls -l /db/day_file/{$prefix}*${file_date}*{$suffix}) The files in the directory /db/day_file are as below. 20170501 20170501... (7 Replies)
Discussion started by: nalu
7 Replies

2. Shell Programming and Scripting

Sed script not working properly on Solaris (works fine on AIX)?

Hi, I have a problem with a SED script that works fine on AIX but does not work properly on a Solaris system. The ksh script executes the SED and puts the output in HTML in tables. But the layout of the output in HTML is not shown correctly(no tables, no color). Can anyone tell if there is... (7 Replies)
Discussion started by: Faith111
7 Replies

3. Shell Programming and Scripting

Moving old files bash script - not working properly

I'm trying to write a script that moves data that's older than 2 weeks to a different place. It works well, EXCEPT, that when the script hits a file within a directory inside the working directory, it will move it to the root of the destination directory instead of putting it in the correct... (1 Reply)
Discussion started by: ugolee
1 Replies

4. Shell Programming and Scripting

Shell script not working properly

Hello, i have below shell script to process ftp get from server and create file list afte finish. this shell scipt has 6 parameter input. unfortunately, it is only working to get the file and terminated before creating file list. please help. thanks, #!/bin/ksh ## example usage :... (3 Replies)
Discussion started by: daryatmo
3 Replies

5. Homework & Coursework Questions

I need to make a script that has 4 command line arguments to function properly.

I have no idea what the following means. The teacher is too advanced for me to understand fully. We literally went from running a few commands over the last few months to starting shell scripting. I am not a programmer, I am more hardware oriented. I wish I knew what this question was asking... (3 Replies)
Discussion started by: Wookard
3 Replies

6. Shell Programming and Scripting

Shell Script Email not working Properly

Hi GURU's, I'm using a Shell Script to send email's as an attachment. I'm Storing the email address in a table and catching in a variable. MAILLIST=`noarg sqlplus -s $OraUsr << EOF set heading off set feedback off set echo off SELECT email_ids FROM tpemail_table WHERE... (9 Replies)
Discussion started by: karthikraj
9 Replies

7. Shell Programming and Scripting

Script not working..."sort" not working properly....

Hello all, I have a file - 12.txt cat 12.txt =============================================== Number of executions = 2 Total execution time (sec.ms) = 0.009883 Number of executions = 8 Total execution time (sec.ms) = 0.001270 Number of... (23 Replies)
Discussion started by: Rahulpict
23 Replies

8. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

9. HP-UX

FC card not working properly

Hi I've a problem with Hp-ux 11.11 9000/800/rp3440 system. Already the software for driver & its patch are loaded for HBA Fibrechannel card, but still the fibrechannel card is showing the status "Unclaimed" . What will be reason for this? How to get the status "Claimed" ? Pl. help me out.... (4 Replies)
Discussion started by: Mike1234
4 Replies

10. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\>§ "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies
Login or Register to Ask a Question