bash: ./<scriptname>: No such file or directory


 
Thread Tools Search this Thread
Operating Systems Solaris bash: ./<scriptname>: No such file or directory
# 8  
Old 06-29-2007
Network

Ok,

I looked up the commands unix2dos and thought dos2unix might be better? I have converted the file to unix format......and still same problem.
# 9  
Old 06-29-2007
doh! of course dos2unix


post the script
# 10  
Old 06-29-2007
Java

#!/bin/sh

# script to take a nrvoucher file and convert it into cards,
# and print them on printer
#
# runs automatically if FILEIN = /tmp/nrcard , else propmts for filename
#
# added formfeed at end of last voucher
#
# prints multiple files but does not secure them at the moment afterwards
# also aborts if "NNDR BILL PRODUCTION" file sent instead of a voucher file.
#
# 8.4.04 if amount is 0.00 do not print date and amount on card
#
# 13.4.04 check if filename is not blank
#
# 1.6.04 modified error message
#
# PSS
#

# this script needs to run as aisdba

. /usr/local/bin/ts

user="`id | cut -d\( -f2 | cut -d\) -f1`"
if [ "$user" != aisdba ]
then
echo "cannot run this script as $user, need to be aisdba"
exit 0
fi

cd /tmp


echo "\nNNDR Card Print Program"
echo "=======================\n"

if [ $# -eq 1 ]
then
if [ "$1" = "menu" ]
then
echo "Are you sure to want to run this program (y/n) : \c"
read reply

case $reply in
y|Y) : continue ;;
*) exit 0 ;;
esac

else
echo "\nUsage : nrcardprint | nrcardprint menu\n"
exit 0
fi

fi

rm /tmp/nrcard.prn 2>/dev/null

FILEIN=`ls nrcard*`

if [ "$FILEIN" = "" -a "$1" = "menu" ]
then
echo "\nEnter file name ( 'ctrl + c' to exit )\n"
read userinp

else
userinp=$FILEIN
fi

if [ "$userinp" = "" ]
then
echo "\nERROR : No card files to process....or files named incorrectly"
echo " File names should be like..../tmp/nrcard\n"
exit 0
fi

if [ -r /tmp/$userinp ]
then
INFILE=/tmp/$userinp
else
echo "\nERROR: Filename does not exist....try typing without path\n"
exit 0
fi

echo "\nProcessing file....\n"

FILECHECK=`grep "NNDR BILL PRODUCTION" $INFILE | wc -l | sed 's/ //g'`

if [ $FILECHECK -ne 0 ]
then
echo "\nERROR : Incorrect file type...tell Sue\n"
exit 0
fi



#=======================================================================

# now print the cards on printer PRINTER

# define variables
CFILE=/tmp/nrcardfile
TMPCARD=/tmp/tmpnrcard
TMPFILE=/tmp/nrcard.tmp
OUTCFILE=/tmp/nrcard.prn
AMOUNTFILE=/tmp/amount.tmp
LOGFILE=/endc/logs/nrcard.log
SECUREDIR=/spare/nr/secure
PRINTER=printronix

# create empty files
>$OUTCFILE
>$TMPFILE
>$AMOUNTFILE

# remove in case it exists already
rm $CFILE 2>/dev/null

cd /tmp

sed 's/^L//g' $INFILE | sed 's/^ //g' | sed '/^0.00/d' | sed '/^ZZZZ/d' > $CFILE

for file in `echo $FILEIN`
do
echo $file
mv $file $SECUREDIR/$file
done

if [ ! -r $CFILE ]
then
echo "$CFILE does not exist"
exit 0
fi

if [ `wc -l $CFILE | awk '{print $1}'` -eq 0 ]
then
echo "$CFILE is empty, no cards to print"
exit 0
fi



# read the file one line at a time, populating the essential fields.
# each entry is separated by a CTRL L, only print payment records when you have
# enough information
linenum=1
formfeed="`echo '\f\c'`"
print=yes
linenum=1
cardnum=0
amountnum=0
oldnrcustomer=xxxx

while
inputline="`line`"
do

inputline=`echo "$inputline" | sed 's/^L//'`

case "$linenum" in
1) : customer reference
reference="`echo $inputline`"
if [ "$reference" = "$oldnrcustomer" ]
then
print=no
else
# change of customer
cardnum=`expr $cardnum + 1`
oldnrcustomer=$reference
print=yes

custtotal=0

payments=`awk '{print($2)}' $AMOUNTFILE`

for payment in $payments
do
custtotal=`bc <<EOB
scale=2
$custtotal + $payment
quit
EOB`

done

cat $AMOUNTFILE >>$OUTCFILE

ed - $OUTCFILE <<EOE
/@@/s/@@/$custtotal/
w
q
EOE

echo '\f' >>$OUTCFILE
echo "\n\n\n\n XXXXXXXXXX\n" >>$OUTCFILE
echo "\n\n\n\n\n\n\c" >>$OUTCFILE

fi
;;


2) : date/amount
date="`echo "$inputline" | cut -c1-12`"
date="`echo $date`"
# nndr cards dont always have dates
if [ ! "$date" ]
then
# Sue now does not want entry if no date
##date="`date +%d.%m.%Y`"
echo ""
fi
amount="`echo "$inputline" | cut -c13-99`"
currency=""
firstchar="`echo "$amount" | cut -c1`"
case "$firstchar" in
[0123456789]) : number, do nothing
;;
*) : remove first char which is currency
amount="`echo "$amount" | cut -c2-99`"
currency="`echo "\0216\c"`"
;;
esac

# if no amount then amount = 0.00, since today's
# date is printed anyway as due date
amount=`echo $amount | sed 's/ //g'`

case $amount in
[0-9]*) amount="`echo $amount`" ;;
*) : Sue does not want 0.00 printing
##amount="0.00"
;;
esac

if [ "$print" = yes ]
then
echo " $date $amount" >$AMOUNTFILE
else
echo " $date $amount" >>$AMOUNTFILE
fi
;;
3) : name1
name="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $name" >>$OUTCFILE
fi
;;
4) : name2
name2="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $name2" >>$OUTCFILE
fi
;;
5) : addr1
addr1="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $addr1" >>$OUTCFILE
fi
;;
6) : addr2
addr2="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $addr2" >>$OUTCFILE
fi
;;
7) : addr3
addr3="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $addr3" >>$OUTCFILE
fi
;;
8) : addr4
addr4="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $addr4" >>$OUTCFILE
fi
;;
9) : pcode
pcode="`echo $inputline`"
if [ "$print" = yes ]
then
echo " $pcode" >>$OUTCFILE
fi
;;
esac


if [ "$linenum" = 9 ]
then
# end of card
linenum=1
if [ "$print" = yes ]
then


echo "\n\n\c" >>$OUTCFILE
echo " REFERENCE NO. $reference ISSUE DATE `date +%d/%m/%Y`" >>$OUTCFILE
echo "\n\n\n\c" >>$OUTCFILE
#echo " DUE FOR YEAR @@" >>$OUTCFILE
echo "\n\c" >>$OUTCFILE
echo " DATE DUE AMOUNT DUE" >>$OUTCFILE
echo "\n\c" >>$OUTCFILE
fi
else
linenum=`expr $linenum + 1`
fi

done <$CFILE


# needed to add amount for last customer
custtotal=0



payments=`awk '{print($2)}' $AMOUNTFILE`

for payment in $payments
do
custtotal=`bc <<EOB
scale=2
$custtotal + $payment
quit
EOB`

done
cat $AMOUNTFILE >>$OUTCFILE
ed - $OUTCFILE <<EOED
/@@/s/@@/$custtotal/
w
q
EOED

# adds form feed at end of file
echo '\f' >>$OUTCFILE


TOTALCARDS=`grep ^L $OUTCFILE | wc -l | sed 's/ //g'`
TOTALCARDS=`expr $TOTALCARDS - 1`

echo "$TOTALCARDS Cards Produced" >$LOGFILE
echo "Printing file '$OUTFILE'" >>$LOGFILE

echo "\n$TOTALCARDS Cards Produced...."
echo "\nPrinting file '$OUTCFILE'....\n"

lp -d $PRINTER $OUTCFILE


rm $CFILE $TMPFILE $AMOUNTFILE
# 11  
Old 06-29-2007
MySQL

I have resolved this problem now, the problem being I was using SmartFTP and even though I had changed the settings to transfer as Binary, it was still transferring as ASCII......Think I might stick to Windows FTP explorer!

Thank you for all your help, can get on with the rest of my day now Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sourcing file from parent directory bash

"Debian 9 64x - LXDE" I try to source a file from my parent directory: #!/bin/bash #source.bash . ../links.bash but i get "file not found". I tried . "../links.bash" and . '../links.bash'. I got on all methods the same result. If i use the absolute path it works, but i don't want to... (4 Replies)
Discussion started by: int3g3r
4 Replies

2. UNIX for Beginners Questions & Answers

Reading a file from a different directory in a Bash script

Hi all, Given here under a section of a script I am using. SIMDIR="/home/Ins/forces" cd $SIMDIR for file in `ls *.forces` do basename=`echo $file | sed 's/\.*$//'` extname=`echo $file | sed 's/*\(*\)\.\(.*\)/\2\1/'` echo "Processing file: "$basename python convert.py... (4 Replies)
Discussion started by: Theo Score
4 Replies

3. Shell Programming and Scripting

Should I run scripts like sh /absolute_path/to/scriptname.sh or just /absolute_path/to/scriptname.sh

Shell : Linux Bash OS version : RHEL 6.X, Oracle Linux 6.X Question1. To execute shell scripts, sometimes I see Linux admins placing sh command before shell scripts like below sh /home/appadmin/sync_pending_orders.shBut, I execute shell scripts like below ie. Just the absolute path ... (4 Replies)
Discussion started by: John K
4 Replies

4. Shell Programming and Scripting

Bash to select and save file in new directory

I am trying to select a file in bash and save it to a directory. The below does run but no selected file is saved. Thank you :). bash # select file printf "please select a file to analyze with entered gene or genes \n" select file in $(cd... (4 Replies)
Discussion started by: cmccabe
4 Replies

5. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

6. Shell Programming and Scripting

Bash to delete file in directory

Will the below bash delete all the "snps.ivg" in the given directory? Thank you :) find N:\all_array\Samples -maxdepth 1 -type f -name "snps.ivg" -delete (6 Replies)
Discussion started by: cmccabe
6 Replies

7. Linux

bash:umount/: no such file or directory

I am trying to connect two system (let's say for time being) together such that it supports clustering. for this I got the following packages: # sudo apt-get install pacemaker sysv-rc-conf glusterfs-server glusterfs-examples glusterfs-client chkconfig nmap ntp Next, I did... (0 Replies)
Discussion started by: dr_mabuse
0 Replies

8. Shell Programming and Scripting

#!/bin/bash cannot find file or directory

Hello, When i run a bash script on ubuntu i get this message.. #!/bin/bash cannot find file or directory... Can anibody help me with this, because the file actually exists.... Is there any extra configuration to be made? (5 Replies)
Discussion started by: oliveiraum
5 Replies

9. Shell Programming and Scripting

bash: How to send a file/directory as argument?

Hi, I'd like to make a script where I can send a directory OR files as an argument, and compress them. My proble mis, I do know how to send a directory, but I do not know what to do if there are more than 1 file, I mean I can store the directory in $1, but how do I store 4 files? must I write $1,... (3 Replies)
Discussion started by: lamachejo
3 Replies

10. Shell Programming and Scripting

FIle (directory) test operator (bash)

I'm almost pulling out my hair trying to figure out what's wrong with this... there's no reason I can see that it shouldn't be working. It seems that the code acts as though the conditional statement is true no matter what - I've even tried removing the negation operator, but it always goes into... (5 Replies)
Discussion started by: wildbluefaerie
5 Replies
Login or Register to Ask a Question