File Not found - Bash script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File Not found - Bash script
# 1  
Old 10-16-2013
File Not found - Bash script

I'm facing issues in executing the bash script of mine. This script will pick the latest file received and connects SFTP server and files is placed on this remote server.
Error message
HTML Code:
Enter password:
"File movement"
sftp> cd Test
sftp> put Test_File_201309.txt
File "Test_File_201309.txt" not found.
Portion of Code
Code:
cd /somefolder/$folder_name
file1_To_Copy=`ls -tr *"$keyword1"*."$ftype" | tail -n 1`


if [[ condition1 == condition2 ]]
then 
echo "File movement"
sftp host@abc.com <<EOF
cd Test
put ${file1_To_Copy}
EOF
fi

Any help is greatly appreaciated Thank you
# 2  
Old 10-16-2013
Your output can't be correct. [[ condition1 == condition2 ]] can never be true.

(not to mention why Enter password: comes before "File movement", or even why "File movement" has quotes around it)

If you expect accurate help, you should provide accurate information.
# 3  
Old 10-16-2013
Scott, Here is the output ..
Code:
File movement
connecting to host@abc.com..
Enter password: 
sftp> cd Test
sftp> put Test_File_201309.txt
File "Test_File_201309.txt" not found.

---------- Post updated at 08:18 AM ---------- Previous update was at 08:05 AM ----------

Also the if statement is something like this

Code:
if [[ a == b ]]

-- Apologies if am not clear with my requirements. Thank you

Last edited by parpaa; 10-16-2013 at 11:57 PM..
# 4  
Old 10-17-2013
Check that your sftp is in the local directory you think it is (lpwd)* and that the file does exist (lls). Also check you don't have any whitespace in the filename.

* - it should be in the current working directory, but I forget if you can configure sftp to start somewhere else by default.
# 5  
Old 10-17-2013
Hi CarloM

Thank you so much for your response, Unfortunately bash scripting is very new to me. I dont know how to do the checks which you asked me to do Smilie We dont have any whitespaces in file name

Thanks again
# 6  
Old 10-17-2013
Just add them to the heredoc for your SFTP session:
Code:
sftp host@abc.com <<EOF
lpwd
lls
cd Test
put ${file1_To_Copy}
EOF

This User Gave Thanks to CarloM For This Post:
# 7  
Old 10-17-2013
file is not available on local working directory. let me copy tat to local directory and will check ..

---------- Post updated at 03:05 PM ---------- Previous update was at 03:00 PM ----------

Thanks Carlo.. it worked.. Thank you so much
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to skip if file not found in bash?

Hello, I have a question regarding while loop and existence of files. I am running under ubuntu 18.04 bionic, have around fifty video files inside the directory. script: for file in *.mp4 do /root/bin/ffmpeg -i $file \ -i $(basename "${file/.mp4}").bs.srt \ -i $(basename... (12 Replies)
Discussion started by: baris35
12 Replies

2. Shell Programming and Scripting

Bash to search file for string and lauch function if found

In the bash below I am searching the filevirus-scan.log for the Infected files: 0 line (in bold) and each line for OK. If both of these are true then the function execute is automatically called and processing starts. If both these conditions are not meet then the line in the file is sent to the... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Bash - trap error file not found

Hello. In bash, is there a way to trap error "file not found" when a script call another script which is not found; then abort. Example ( part of script running with -x option set) : + return 0 + RETURN_CODE=0 + ] + /root/bin/200_yast_install/00_reset_yast_install bash:... (5 Replies)
Discussion started by: jcdole
5 Replies

4. Shell Programming and Scripting

Bash script fails with "function: not found" error

Hello everyone, I am having problems figuring this out. This script below is supposed to create a list of file names with their "md5sum", in a file "lib-list.txt" When I run it "sh component-list.sh " I get this:component-list.sh: 4: component-list.sh: function: not found component-list.sh:... (4 Replies)
Discussion started by: joemb
4 Replies

5. UNIX for Dummies Questions & Answers

Im new to bash scriping and i found this expression on a bash script what does this mean.

# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi espeacailly the top regex part? ---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
Discussion started by: kevin298
1 Replies

6. Shell Programming and Scripting

bash script search file and insert character when match found

Hi I need a bash script that can search through a text file and when it finds 'FSS1206' I need to put a Letter F 100 spaces after the second instance of FSS1206 The format is the same throughout the file I need to repeat this on every time it finds the second 'FSS1206' in the file I have... (0 Replies)
Discussion started by: firefox2k2
0 Replies

7. Shell Programming and Scripting

rm:command not found in linux Bash shell script

Hi All, Linux lxs3er06 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux Issue: While executing shell scripts in bash shell, following error messages are thrown: rm:command not found On doing little investigation, I added '/bin' to $PATH and on doing echo... (9 Replies)
Discussion started by: a1_win
9 Replies

8. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

9. Shell Programming and Scripting

bash script tail when string found do something

Okay, I have two scripts, the first one does some stuff, and comes to a point where it has this: Right here it runs a quick script to start something that writes to a log file. /usr/bin/tail -f ${pathVar}/nohup_${servVar}.out | while read -r line do ] && continue cd ${pathVar}... (0 Replies)
Discussion started by: cbo0485
0 Replies

10. HP-UX

bash...Not found through where(compiling source file)

Hi i have compiled and installed bash 3.2 on my hp-ux parisc its in path /usr/local/pkg/bash/bin/bash .....When im search for this bash (through whereis bash) im not findind but other which i hve done in same procedure( gettext,m4) ..Im able to find through whereis search option can any1... (3 Replies)
Discussion started by: vasanthan
3 Replies
Login or Register to Ask a Question