Tag Archives: PWD

Fetching variable from config file

By rafa_fed2

I am using . .profile in my script below
I want to fech it it from my configuration file .id_pass_file.txt(it has all user_name and passwords)
how can i do this

Code:

PROFILE_PATH=. .profile
AND IN MY SCRIPT
$PROFILE_PATH
IS THIS CORRECT


Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

## /path/to/profile .This is required for crontab to work as bip.sh uses environmental variables.
. .profile

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select distinct account_no from adj WHERE ADJ_TRANS_CODE=-2401 and request_status=1 and bill_ref_no=0
order by account_no;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
sh $SCRIPT_DIR/bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 180
done
fi

###Removing temporary log files generated

if [ -f "$CUR_DIR/bip_log_1.txt" ]
then
rm "$CUR_DIR/bip_log_1.txt"
echo "file bip__log_1.txt removed"
fi

if [ -f "$CUR_DIR/sql_output.txt" ]
then
rm "$CUR_DIR/sql_output.txt"
echo "sql_output.txt removed"
fi

rm $CUR_DIR/error.log


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Issue with cron and environmental variable

By rafa_fed2

My shell script it.sh.I am calling bip.sh from it.sh

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f $CUR_DIR/bip_log_1.txt ]
then
`rm $CUR_DIR/bip_log_1.txt`
echo "file bip__log_1.txt removed"
fi

if [ -f $CUR_DIR/sql_output.txt ]
then
`rm $CUR_DIR/sql_output.txt`
echo "sql_output.txt removed"
fi


Code:

59 04 * * * /arbor/integ_fx/rahul_raj/itsr_5652/it.sh /arbor/integ_fx/rahul_raj/itsr_5652


my error.log file

Code:

LOGGING STARTS 07-22-2013 05:22:00

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 1016 is running
cat: cannot open /.arborpw
file bip__log_1.txt removed
sql_output.txt removed.
ERROR: $ARBORDBU environment variable is not set

This script requires that the $ARBORDBU environment variable be set.


MY BIP.SH

Code:

#!/bin/sh
ARBOR_DB_PASSWD=`cat $ARBORDIR/.arborpw`; export ARBOR_DB_PASSWD
DB_PASS=$ARBOR_DB_PASSWD; export DB_PASS;
ORACLE_SID=$ARBOR_CATALOG_DATABASE; export ORACLE_SID;
ARBORCTRLRPT03=$ARBORDATA/reports/ctrl; export ARBORCTRLRPT03;

Usage(){
echo "nn Usage is: `basename $0` n"
echo " where is a number between 01 and 99"
echo " is a number. Use 0=production, 3=proforma, 6=backout"
echo " is an arbor accout numbernn"
exit 0
}

# Check number of arguments
if [ "$#" -ne 3 ] ; then
Usage
fi

# Check to see if ARBORDBU is set
if [ -z "${ARBORDBU}" ] ; then
echo "ERROR: $ARBORDBU environment variable is not setn"
echo "This script requires that the $ARBORDBU environment variable be set.nn"<br ...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Scheduling issues

By rafa_fed2

I AM ON SOLARIS

I have a script it.sh which is running fine when i execute it from shell command.
But when i schedule it in crontab it is throwing error.

Why and how can i resolve it ?i am clueless

IT.SH

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select distinct account_no from adj WHERE ADJ_TRANS_CODE=-2401 and request_status=1 and bill_ref_no=0
order by account_no;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
sh $SCRIPT_DIR/bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 180
done
fi


My error is in error.log

Code:


LOGGING STARTS

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 114034 is running
cat: cannot open /.arborpw


my error is bip_log_1.txt

Code:

ERROR: $ARBORDBU environment variable is not set

This script requires that the $ARBORDBU environment variable be set.


My bip.sh is

Code:

#!/bin/sh
ARBOR_DB_PASSWD=`cat $ARBORDIR/.arborpw`; export ARBOR_DB_PASSWD
DB_PASS=$ARBOR_DB_PASSWD; export DB_PASS;
ORACLE_SID=$ARBOR_CATALOG_DATABASE; export ORACLE_SID;
ARBORCTRLRPT03=$ARBORDATA/reports/ctrl; export ARBORCTRLRPT03;

Usage(){
echo "nn Usage is: `basename $0` n"
echo " where is a number between 01 and 99"
echo " is a number. Use 0=production, 3=proforma, 6=backout"
echo " is an arbor accout numbernn"
exit 0
}

# Check number of arguments
if [ "$#" -ne 3 ] ; then
Usage
fi

# Check to see if ARBORDBU is set
if [ -z "${ARBORDBU}" ] ; then
echo "ERROR: $ARBORDBU environment variable is not setn"
echo "This script requires that the $ARBORDBU environment variable be set.nn"
...read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Files not being removed

By rafa_fed2

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f "$CUR_DIR/bip_log_1.txt" ]
then
rm "$CUR_DIR/bip_log_1.txt"
echo "file bip__log_1.txt removed"
fi

if [ -f "$CUR_DIR/sql_output.txt" ]
then
rm "$CUR_DIR/sql_output.txt"
echo "sql_output.txt removed"
fi


My error

error.log

Code:

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 1016 is running
file bip__log_1.txt removed
./it.sh: syntax error at line 76: `end of file' unexpected


how do i remove sql_output.txt

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Another issue with crontab

By rafa_fed2

My shell script it.sh

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=$CUR_DIR/error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f $CUR_DIR/bip_log_1.txt ]
then
`rm $CUR_DIR/bip_log_1.txt`
echo "file bip__log_1.txt removed"
fi

if [ -f $CUR_DIR/sql_output.txt ]
then
`rm $CUR_DIR/sql_output.txt`
echo "sql_output.txt removed"
fi


when i execute the script manually ,it is working fine but when i schedule this job in crontab i get an error in error.log

Why?
Please help me.

crontab entry

Code:

59 04 * * * /arbor/integ_fx/rahul_raj/itsr_5652/it.sh /arbor/integ_fx/rahul_raj/itsr_5652


Code:


LOGGING STARTS 07-22-2013 05:22:00

SQLPLUS CONNECTION
SQLPLUS Connection Successful
bip 1016 is running
cat: cannot open /.arborpw
file bip__log_1.txt removed
sql_output.txt removed


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Log file being not generated in crontab

By rafa_fed2

My shell script it.sh

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f $CUR_DIR/bip_log_1.txt ]
then
`rm $CUR_DIR/bip_log_1.txt`
echo "file bip__log_1.txt removed"
fi

if [ -f $CUR_DIR/sql_output.txt ]
then
`rm $CUR_DIR/sql_output.txt`
echo "sql_output.txt removed"
fi


when i execute the script manually ,it is working fine but when i schedule this job in crontab error.log file is not generated

Why?
Please help me.

crontab entry

Code:

59 04 * * * /arbor/integ_fx/rahul_raj/itsr_5652/it.sh /arbor/integ_fx/rahul_raj/itsr_5652


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Removing log files

By rafa_fed2

Code:

#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`; export today
CUR_DIR=$1; export CUR_DIR

LOG_FILE=error.log; export LOG_FILE

# Direct script output to log
exec > $LOG_FILE 2>&1

echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`cat .id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat .id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat .id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat .id_pass_file.txt | grep "^SID" | cut -d "=" -f2`; export SID

### Connecting ORACLE

echo "SQLPLUS CONNECTION"

sqlplus -s $USER_ID@$SID/$PWD<$CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF

if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi

##echo " The account numbers to be used in BIP are "

if [ ! -s "sql_output.txt" ]
then
echo "No account number for bad debt"
else
for i in `cat sql_output.txt`
do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt
sleep 100
done
fi

###Removing temporary log files generated

if [ -f $CUR_DIR/bip_log_1.txt ]
then
`rm $CUR_DIR/bip_log_1.txt`
echo "file bip__log_1.txt removed"
fi

if [ -f $CUR_DIR/sql_output.txt ]
then
`rm $CUR_DIR/sql_output.txt`
echo "sql_output.txt removed"
fi

rm $CUR_DIR/error.log


I want to remove the 3 files that are being genarated.
How can i do this
I am getting an error

Code:

file bip__log_1.txt removed
./it.sh: syntax error at line 76: `end of file' unexpected


My code should work for all paths that i give

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Getting a command not found when comparing in tsch

By tastybrownies

Hey everyone,

I am almost done with this assignment I have to do but there is one last thing nagging me that I can’t seem to find. In my script I am feeding line by line to a ./test file and I am getting the return answer correctly. The goal is to test the current script (check.sh) and if it’s output is the same as the testcase.txt file then everything is good. So I have most of the script done but am still getting the “command not found” issue. I’m thinking it’s something with my if statement and possibly the comparison. If anyone could point me in the right direct or let me know how to get rid of this error, I would sincerely appreciate it!!! Thank you! Below is my program and then the output it gives.

Code:

set dir="$PWD/./test"
set dir2="$PWD/testcase.txt"
set ODD=""
set EVEN=""
set oddlines=`sed -n 1~2p $PWD/testcase.txt > ODD`
set evenlines=`awk NR%2==0 $PWD/testcase.txt > EVEN`
set fodd=$PWD/ODD
set odd="`cat $PWD/ODD`"
set even="`cat $PWD/EVEN`"
set FILERETURN=""
set i=1
set j=1
set counttot=0
set countpass=0

while ($i <= $#odd)
while ($j <= $#even)

set FILERETURN=(`echo $odd[$i] | $dir`)

#echo $FILERETURN
#echo $even[$j]
if $FILERETURN == $even[$j]
@ countpass = $countpass + 1
endif
#echo $odd[$i]

#echo $even[$j]
@ counttot = $counttot + 1
@ i = $i + 1
@ j = $j + 1
end
end

echo "passed/total tests" $countpass "/" $counttot
rm ODD EVEN


Code:

% check.sh
-1: Command not found.
0: Command not found.
-1: Command not found.
-1: Command not found.
-1: Command not found.
-1: Command not found.
-1: Command not found.
0: Command not found.
passed/total tests 10 / 10


From: http://www.unix.com/homework-coursework-questions/221105-getting-command-not-found-when-comparing-tsch.html

Reading in two lines at once from a text file

By tastybrownies

Hello everyone,

I have thought about this for quite some time and know what I want to do but am having some trouble at it. I have a text file filled with numbers like this, there are more in the file obviously. Each number is separated by a space.

Code:

1 3 2 4 5
1 -1 1 0 -1 5


The idea is to use these numbers to calculate some kind of a profit. The first line is price per item and the second line indicates an action. 1 means you bought it, -1 means you sold it, 0 means no action. So, to demonstrate things, you buy an item at $1, the running total is -1, you sell (add 3), subtract 2, ignore the no transaction, then add 5, leaving you with 5. Anyway I am trying to read 2 lines in at a time in TSCH (don’t respond telling me that it’s harmful, I have to use it in this situation) and check to see whether the ending profit is correct. I am thinking I can read in 2 lines at once, store them in different variables, and then compute a running total for the lines by using indexes in each variable. Saying, comparing line1[0] and line2[0] and so on. If line2[i] is negative that means add and vice versa. If anyone offer a solution or point me in the right direction I would greatly appreciate it! I have one line being read in but do not know how to get the second line.

Code:

set lines=`cat $PWD/testcase.txt`
set i=1

while ($i <= $#lines)
echo $lines[$i]
@ i = $i + 1
end


From: http://www.unix.com/shell-programming-scripting/221059-reading-two-lines-once-text-file.html

User input in perl code

By ajayram_arya

Hello friends . I am newbie to perl scripting but still managed to write a code but i am stuck at a place where i need help . Below is the code and can someone help me in taking user input for changing the font size for a html table .Thank you in advance

#!/bin/ksh
echo ” Enter the Directory Location of the dat file :”
read fname
cd $fname
echo ” Current directory `pwd`:”
echo ” Enter the filename : “
read Filename
if [ -f $Filename ];
then
echo ” File exists.”
sed ‘s/ /,/g’ $Filename > $Filename.csv
print “Enter the size”;
read size
$fontsize = $size
perl -F’,’ -lane ‘BEGIN{
$pct_col=0;
@bgc=(“white”);
open O, “>output_db.html”; print O “


};
chomp;
print O “

“;
#print “Enter the size”;
for $i (0..@F-1) {
$cbgc=@bgc[$i % 1];
if (${i} >= ($pct_col + 5)) {
$pct=@F[$i];
$pct=~s/ *[%].*$//;
$pct=~s/^ *//;
$cbgc=”red” if ($pct > 10);
$cbgc=”orange” if ($pct > 5 && $pct <= 10);
$cbgc=”yellow” if ($pct > 2 && $pct <= 5);
$cbgc=”white” if ($pct = -2);
$cbgc=”cyan” if ($pct = -5);
$cbgc=”lightsteelblue” if ($pct > -5 && $pct <= -10);
$cbgc=”purple” if ($pct < -10);
}
# print O “


print O “


}
print O “

“;
END {print O “

@F[$i] @F[$i]

“; close O}’ $Filename.csv
#END {print O “”; close O}’ change.trend.wt.dat.csv

else
echo “File doesnt exist—-> exiting”
exit;
fi

PWD=`/bin/pwd`
echo “Enter the Distribution list name:”
read DISTLIST
#for i in `cat $DISTLIST`
#do
echo “sending data to the distribution list”
/opt/csw/bin/mpack -s “Datafeed HTML page” $PWD/output_db.html `cat $DISTLIST`
#done

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to save and execute terminal commands in shell?

By Akshay Hegde

I frequently use some commands, which I want to save in some file say

Code:

myregularshell.sh


these are the commands I use, I tried saving and executing, but couldn’t get the preview of execution, and result is also not coming if I copy same commands and paste it on terminal result is coming

Code:

cd go somewhere

echo "I am here $PWD"

sudo su

source /etc/profile

sh operation.sh arguments

echo "Operation over"

find /mypath/path iname "*.abc" -delete

echo "old files deleted"

mv -i *.xyz /mypath/path

echo "new files moved "


Is there any way to save as shell script and execute ?

Source: FULL ARTICLE at The UNIX and Linux Forums

Cross Compilig Issue of udev-151 for MIPS Little Endain Architecture

By bsreeram

Hi All,
I am trying to cross compile udev-151 for MIPS little endian architecture.

I am configuring like this:

./configure –prefix=$PWD/sree –host=mips-linux-gnu

configure: WARNING: If you wanted to set the –build type, don’t use –host.
If a cross compiler is detected then cross compile mode will be used.
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for mips-linux-gnu-strip… mips-linux-gnu-strip
checking for a thread-safe mkdir -p… /bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking for style of include used by make… GNU
checking for mips-linux-gnu-gcc… mips-linux-gnu-gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… yes
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether mips-linux-gnu-gcc accepts -g… yes
checking for mips-linux-gnu-gcc option to accept ISO C89… none needed
checking dependency style of mips-linux-gnu-gcc… gcc3
checking how to run the C preprocessor… mips-linux-gnu-gcc -E
checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking minix/config.h usability… no
checking minix/config.h presence… no
checking for minix/config.h… no
checking whether it is safe to define __EXTENSIONS__… yes
checking for special C compiler options needed for large files… no
checking for _FILE_OFFSET_BITS value needed for large files… 64
checking build system type… x86_64-unknown-linux-gnu
checking host system type… mips-unknown-linux-gnu
checking for a sed that does not truncate output… /bin/sed
checking for fgrep… /bin/grep -F
checking for ld used by mips-linux-gnu-gcc… /home/intel/mips-4.3/mips-linux-gnu/bin/ld
checking if the linker (/home/intel/mips-4.3/mips-linux-gnu/bin/ld) is GNU ld… yes
checking for BSD– or MS-compatible name lister (nm)… /home/intel/mips-4.3/bin/mips-linux-gnu-nm -B
checking the name lister (/home/intel/mips-4.3/bin/mips-linux-gnu-nm -B) interface… BSD nm
checking whether ln -s works… yes
checking the maximum length of command line arguments… 1572864
checking whether the shell understands some XSI constructs… yes
checking whether the shell understands “+=”… yes
checking for /home/intel/mips-4.3/mips-linux-gnu/bin/ld option to reload object files… -r
checking for mips-linux-gnu-objdump… mips-linux-gnu-objdump
checking how to recognize dependent libraries… pass_all
checking for mips-linux-gnu-ar… mips-linux-gnu-ar
checking for mips-linux-gnu-strip… (cached) mips-linux-gnu-strip
checking for mips-linux-gnu-ranlib… mips-linux-gnu-ranlib
checking command to parse /home/intel/mips-4.3/bin/mips-linux-gnu-nm -B output from mips-linux-gnu-gcc object… ok
checking for dlfcn.h… yes
checking for objdir… .libs
checking if mips-linux-gnu-gcc supports -fno-rtti -fno-exceptions… no
checking for mips-linux-gnu-gcc option to produce PIC… -fPIC -DPIC
checking if mips-linux-gnu-gcc PIC flag -fPIC -DPIC works… yes
checking if mips-linux-gnu-gcc static flag -static works… yes
checking if mips-linux-gnu-gcc supports -c -o file.o… yes
checking if mips-linux-gnu-gcc supports -c -o file.o… (cached) yes
checking whether the mips-linux-gnu-gcc linker (/home/intel/mips-4.3/mips-linux-gnu/bin/ld) supports shared libraries… yes
checking whether -lc should be explicitly linked in… no
checking dynamic linker characteristics… GNU/Linux ld.so
checking how to hardcode library paths into programs… immediate
checking whether stripping libraries is possible… yes
checking if libtool supports shared libraries… yes
checking whether to build shared libraries… yes
checking whether to build static libraries… no
checking for gawk… (cached) gawk
checking for mips-linux-gnu-pkg-config… no
checking for pkg-config… /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0… yes
checking for gtkdoc-check… no
checking for gtkdoc-rebase… no
checking for gtkdoc-mkpdf… no
checking whether to build gtk-doc documentation… no
checking for xsltproc… /usr/bin/xsltproc
checking for gperf… /usr/bin/gperf
checking for GLIB… yes
checking for acl_init in -lacl… no
configure: error: libacl not found

Please guide me to fix this error. I also have installed libacl using sudo -apt-get install command. yet it throws error while configuring it.

Source: FULL ARTICLE at The UNIX and Linux Forums

I have no idea what is wrong with my simple script.

I am doing a simple “recycle bin” script. It is to check and see if the directory .TRASH exists within the home directory. If not then it makes the directory then appends a date and time to file and then finally moves the file in. However, when I run this script, it is not making the directory as it should.

What am I missing?

Code:
#!/bin/bash
if [ -d “~/.TRASH” ]
then
mkdir ~/.TRASH
fi

DT=$(date +’_%Y%m%d_%H%M’)
mv $PWD/”$1″ “~/.TRASH/${1}.${DT}”

Source: The UNIX and Linux Forums