Shell script running command in different shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script running command in different shell
# 8  
Old 05-23-2011
Hi,
Then change the first line of the script from #!/bin/sh to #!/bin/bash
No ?
# 9  
Old 05-23-2011
Quote:
Originally Posted by gr8_usk
I tried .... still no luck .....

Please find my script below,

Code:
#!/bin/sh
set -x
TREE="$1"
cd $TREE
for FILENAME in FILE1 FILE2 FILE3
do
        ABS_NAME=`find $TREE -name $FILENAME -print -follow  2>/dev/null`
        dir_name=`dirname ${ABS_NAME}`
        FILE=`basename ${ABS_NAME}`
        cd $dir_name
        LAST_CHAR=`od -An -tc -j $(( $(ls -l $FILE  | awk '{print $5}') - 1 )) $FILE | awk '{print $1}' | sed '/^$/d'`
        if [ "${LAST_CHAR}" != "\\n" ]
        then
                echo "New line character is missing in $FILE."
        else
                echo "$FILE ok"
        fi
done

I wanted to use "/bin/bash" for below line in script,

Code:
LAST_CHAR=`od -An -tc -j $(( $(ls -l $FILE  | awk '{print $5}') - 1 )) $FILE | awk '{print $1}' | sed '/^$/d'`

---------- Post updated at 08:32 PM ---------- Previous update was at 08:30 PM ----------

Basically the above line should get executed with /bin/bash shell as /bin/sh is having some limitations ....

remove LAST_CHAR line , just try this command Smilie
Code:
if [ $(sed -n '$p' $FILE|od -c|sed -n '1s/.*\(..\)$/\1/p') == "\n" ]

regards
ygemici
# 10  
Old 05-23-2011
Ok, then let's begin with the begining Smilie

What is the system where you wanna do that and the shell & version.
Maybe you could show us the output of :
Code:
uname -a
ls -l /bin/sh
sed --version
od --version
awk --version
grep --version
tail --version

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Troubles running DB2 command in shell script via cron

Hi there, Now I'm facing error regarding running shell script via cron. The shell script which is required to get value from database. Below is the main part of shell script. #/bin/bash #connect to database(1) db2 connect to $database user xxxx using yyyy #set values from... (3 Replies)
Discussion started by: Rohan Kishibe
3 Replies

2. Shell Programming and Scripting

Cp not working in shell script but running perfectly from shell

Dear All, I have script. Dest="" IFS=' ' for translation in $(echo $MY_MAP) do t1=$(echo $translation | cut -d"=" -f1) t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1) if then Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2 break; ... (4 Replies)
Discussion started by: yadavricky
4 Replies

3. Shell Programming and Scripting

Running 3 shell script parallel in another shell script

Hi, I'm trying to do teh below thing. I have a single script which uses 3 different parameters to do 3 different work like belwo. test1.sh par1 -- it shuts down an instance test1.sh par2 -- it shuts down an instance test1.sh par3 -- it shuts down an instance Now I created a script... (7 Replies)
Discussion started by: bhaski2012
7 Replies

4. Shell Programming and Scripting

Changing shell from a script and running something from the new shell

Hi We use "tcsh" shell . We do the following steps manually: > exec ssh-agent zsh > python "heloo.py" (in the zsh shell) I am trying to do the steps above from a shell script This is what I have so far echo "Executing " exec ssh-agent zsh python "hello.py" exit 0 Problem is... (5 Replies)
Discussion started by: heman82
5 Replies

5. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

6. Solaris

Error during running sqlplus command from shell script in Solaris

I am using following code to connect to oracle database from solaris shell script. which will try thrice to connect the database ...at the 4rth atempt it will exir=t. count=0 while ; do sqlplus -s $usrname/$password@dbSID <<-EOF | tee $logfile WHENEVER OSERROR EXIT 9; WHENEVER SQLERROR... (4 Replies)
Discussion started by: millan
4 Replies

7. Shell Programming and Scripting

running shell command in Perl script

Does not work. #!/usr/bin/perl $etcdir = 'ls -l /etc'; print $etcdir; #END ------------result-------- #perl -w abc123.pl ls -l /etc # This method works. #!/usr/bin/perl $etcdir = system("ls -l /etc"); print $etcdir; #END (2 Replies)
Discussion started by: dplinux
2 Replies

8. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

9. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

10. Shell Programming and Scripting

URGENT: cron job not running the sqlplus command in shell script

cron job not running the sqlplus command in shell script but the shell script works fine from command line.. Cronjob: 5 * * * * /home/dreg/script.sh script.sh: #!/bin/ksh /oracle/u000/app/oracle/product/10204/GEN/bin/sqlplus -s <user>/<pass>@<sid/home/dreg/sqlscript.sh ... (18 Replies)
Discussion started by: Ikea
18 Replies
Login or Register to Ask a Question