LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   No Such File or Directory when running the script (https://www.linuxquestions.org/questions/linux-newbie-8/no-such-file-or-directory-when-running-the-script-521883/)

just_a_kid 01-22-2007 08:51 PM

No Such File or Directory when running the script
 
Hi

I have current script running well in production
because there is an additional need so i need to replicated the script and make some changes necessary but the new one doesnt work

here is my script
a.sc
Code:

#! /bin/sh

cd /data/opt/psa/rel/ils/files/edi/tpc2/psa2tpcDir/scriptsDir
pollStockData.sc

pollStockData.sc
Code:

#!/usr/local/bin/expect --

# ====== USER VARIABLES ========================
set timeout 120
set basedir "/data/opt/psa/rel/ils/files/edi/tpc2/psa2tpcDir/scriptsDir"
set normalscript "$basedir/pollStockData_impl.sc"
# ==============================================

set CMD "telnet 192.168.100.191 21"
puts $CMD

log_user 0
eval spawn $CMD
  expect {
    "Escape character is " {
      send "USER ftp\n"
      expect {
        "331 Guest login" {
          puts "1:FTP Connection up-Anon FTP available"
          set CMD $normalscript
        }
        "530 User" {
          puts "4:FTP Connection up-Anon FTP not available"
          set CMD $normalscript
        }
      send "QUIT\n"
        timeout {
          puts "255:Connection timeout"
        }
      }
    }
    "Connection refused" {
      puts "10:Connection refused"
    }
    "Unknown host" {
      puts "100:Unknown host"
    }
    timeout {
      puts "255:Connection timeout"
    }
  }

##set CMD [concat $CMD [lindex $argv 0]]
puts $CMD
system $CMD
exit 0


pollStockData_impl.sc
Code:

#! /bin/sh

## === -------------------------------------------------- ===
## ===  Parameter Input checking                          ===
## === -------------------------------------------------- ===
echo " poll Stock Balance Data IMPL                    "
echo " "
echo " "
echo " -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ "
echo "    Executing script: $0 "
echo " -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ "
if [ "$#" != 0 ]
then
  echo " "
  echo "    Extra parameters ignored ($*)."
  echo " "
  echo " "
fi

## === -------------------------------------------------- ===
## ===  Read in  file data      ===
## === -------------------------------------------------- ===
paraFile=para_sapstock2tpc.txt

ftpAddr=`cat $paraFile | grep "ftpAddr:" | cut -d':' -f2`
inFilePrefix=`cat $paraFile | grep "inFilePrefix:" | cut -d':' -f2`
srcBaseDir=`cat $paraFile | grep "srcBaseDir:" | cut -d':' -f2`
logDir=`cat $paraFile | grep "logDir:" | cut -d':' -f2`


ftp $ftpAddr << ENDFTPHERE
prompt
cd $srcBaseDir
ls ${inFilePrefix}* > $logFile
lcd $destBaseDir
mget ${inFilePrefix}*



what i did

./a.sc
gives me " ": no such file or directory "

then i run
./pollStockData.sc
gives me " ./pollStockData.sc
": no such file or director "

then i tried to run
./pollStockData_impl.sc
gives me " bash: ./pollStockData_impl.sc: No such file or directory "


what did i do wrong..
i already checked all the permission and it seems okay.

Thanks

tbutttbutt 01-22-2007 09:24 PM

Is the current directory in your path?

PATH=.:$PATH

just_a_kid 01-22-2007 09:34 PM

Hi Thanks for the reply

after i type echo $PATH

i get this below
Code:

/usr/bin:/usr/ucb:/etc:.

nilleso 01-22-2007 10:18 PM

what directory are you in when you try to run these commands? (type pwd) ..are you in the same directory as the *.sc scripts?

also, change
Quote:

cd /data/opt/psa/rel/ils/files/edi/tpc2/psa2tpcDir/scriptsDir
pollStockData.sc
to
Quote:

/data/opt/psa/rel/ils/files/edi/tpc2/psa2tpcDir/scriptsDir/pollStockData.sc
cheers:)

nilleso 01-22-2007 10:21 PM

here's another tip... always use full paths in your scripts. You won't get hung up on path issues, you'll save time trying to figure out a old script, and you won't have cronjob issues.
It's a good habit to get into.

just_a_kid 01-22-2007 11:57 PM

Hi thanks for the reply

but i dont think this is a issue


i am in the same directory as .sc script is

thats why i can seee the contents by typing
cat pollStockData.sc


but when i do ./pollStockData.sc it gives no such file or directory


i followed ur way
/data/opt/psa/rel/ils/files/edi/tpc2/psa2tpcDir/scriptsDir/pollStockData.sc


but still same error happens..


any idea guys??

I am trying to use expect to do ftp


The thing there is some existing script that is running well in production
thats why i confuse
all i did is copy and modified some of the things to perform other things

nilleso 01-25-2007 12:13 PM

ah, it probably just isn't executable then. try `chmod +x file`

chmod

fooks 01-25-2007 01:13 PM

hi, try to run scripts with -x option, like:
Code:

$ sh -x pollStockData_impl.sc


All times are GMT -5. The time now is 09:58 AM.