LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2007, 09:51 PM   #1
just_a_kid
LQ Newbie
 
Registered: Dec 2006
Posts: 24

Rep: Reputation: 15
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
 
Old 01-22-2007, 10:24 PM   #2
tbutttbutt
Member
 
Registered: Jan 2006
Location: India
Distribution: Fedora 7, Linuxfromscratch 6.2
Posts: 66

Rep: Reputation: 15
Is the current directory in your path?

PATH=.:$PATH
 
Old 01-22-2007, 10:34 PM   #3
just_a_kid
LQ Newbie
 
Registered: Dec 2006
Posts: 24

Original Poster
Rep: Reputation: 15
Hi Thanks for the reply

after i type echo $PATH

i get this below
Code:
/usr/bin:/usr/ucb:/etc:.
 
Old 01-22-2007, 11:18 PM   #4
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
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
 
Old 01-22-2007, 11:21 PM   #5
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
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.
 
Old 01-23-2007, 12:57 AM   #6
just_a_kid
LQ Newbie
 
Registered: Dec 2006
Posts: 24

Original Poster
Rep: Reputation: 15
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
 
Old 01-25-2007, 01:13 PM   #7
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

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

chmod
 
Old 01-25-2007, 02:13 PM   #8
fooks
Member
 
Registered: Jan 2007
Location: Ukraine
Posts: 47

Rep: Reputation: 15
hi, try to run scripts with -x option, like:
Code:
$ sh -x pollStockData_impl.sc
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron script - No such file or directory mokelly1 Linux - Newbie 5 10-27-2006 03:31 PM
Java File Processing using Scanner; Can't get it to read file in running directory xemous Programming 2 09-26-2006 07:13 PM
Directory file size script yeahflow Linux - Newbie 4 09-03-2006 08:29 PM
script.sh - No such file or directory - ??? ilhbutshm Programming 5 05-26-2004 11:26 AM
Running a script on every file in a directory davee Linux - Newbie 2 11-04-2003 03:34 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration