Bash - sftp simple script problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash - sftp simple script problem
# 1  
Old 09-21-2015
Bash - sftp simple script problem

Hello,
when running the scripts below I am not getting message bb2.
Can you please help?


Code:
 #!/bin/bash
TLOG=/tmp/bb/amatest.log
FTPRESULTS=/tmp/bb/amlist
export TLOG FTPRESULTS
 
>$TLOG
>$FTPRESULTS
 
echo bb1
 
sftp -oPort=2222 XXXXXXXXXXXXX@sftp.userssedi.com  <<EOF
cd download
ls
quit
        EOF
 
echo bb2
  
 ./bbb
 [root@towhee scripts]# ./bbb
bb1
Connecting to sftp.userssedi.com...
sftp> cd download
sftp> ls
testfile
sftp> quit



Thank you
Biljana

Last edited by Corona688; 09-22-2015 at 12:35 PM..
# 2  
Old 09-21-2015
Please add CODE tags (as required by forum rules) to your post. Without them we can't tell where your script ends, we can't tell if spacing at the start of various lines in your script is a problem, and we can't tell what is intended to be output produced by your script.

Please also indicate the name of your script.
# 3  
Old 09-22-2015
What's the contents of "/tmp/bb/amlist" after running the script?
# 4  
Old 09-22-2015
Here is with a code tags - apologize

Sorry this is my script again (called bbb)

Quote:
Code:
 
 #!/bin/bash
TLOG=/tmp/bb/amatest.log
FTPRESULTS=/tmp/bb/amlist
export TLOG FTPRESULTS
 
>$TLOG
>$FTPRESULTS
 
echo bb1
 
sftp -oPort=2222 xxxxxxxxxxxxx@sftp.usertssedi.com  <<EOF
cd download
ls
quit
        EOF
 
echo bb2

amlist is blank file (not important here because scripts doesn't use it).
Also log amatest.log is empty.

Biljana
# 5  
Old 09-22-2015
Try removing EOF 's indentation. Read about "Here documents" in man bash.
# 6  
Old 09-22-2015
Yay! It works. Thank you very much RudiCSmilie

And thanks for a document, found it.

Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only word (with no trailing
blanks
) is seen. All of the lines read up to that point are then used
as the standard input for a command...

Have a great day!

Biljana
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple sftp script not working - Please help

I have the below sftp script to transfer a file from a linux host(source) to another linux host(target). Public key is already set up in target host and I am able to transfer file using sftp from source to target. But not sure why the below script(ftp_script) is not working. Any help in this... (3 Replies)
Discussion started by: Armaan
3 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. Shell Programming and Scripting

Simple bash script help

Hi to everyone here, I'm a new user and relatively-new linuxer. I'm trying to write a script that checks if every file from a directory is present in a given list and if not, delete it. should be simple. But I think I've done half the work only: this is to create the reference list: for c... (2 Replies)
Discussion started by: dentex
2 Replies

4. Shell Programming and Scripting

Simple bash script problem

#!/bin/bash cd /media/disk-2 Running ./run.sh it's not changing directory.Why? (6 Replies)
Discussion started by: cola
6 Replies

5. Shell Programming and Scripting

need a simple bash script

to gather the cpu utilization from a system in 5 minute intervals and direct output to file. I'm new at scripting and while this seems like an easy task I'm confused on where to start. thanks for any help (1 Reply)
Discussion started by: mkeyes001
1 Replies

6. Shell Programming and Scripting

simple bash script

I am writing a shell script in bash one of the thing I want to show is size of export /home du -sk /export/home/oracle | cut -c 1-5 echo "kbytes" when I run the script kbytes shows up in the second line, How can I append kbytes on the same line, such as 61233 kbytes please guide thanks (2 Replies)
Discussion started by: Tirmazi
2 Replies

7. Shell Programming and Scripting

Simple BASH script?

Hi guys, I'm new to the forum so forgive me if I'm sounding ... daft. I currently work in a Tech Support role. Every day we have to generate data by running around 10 .sh scripts. I was thinking instead of having to ./filename 10 times is it possible to right a new script that will run these for... (16 Replies)
Discussion started by: JayC89
16 Replies

8. Shell Programming and Scripting

Simple bash for loop problem

I'm just trying to make a script that runs in command line to echo each line in a text file. Everything i found on google is telling me to do it like this but when I run it it just echos removethese.txt and thats it. Anyone know what im doing wrong? for i in removethese.txt; do echo $i; done ... (4 Replies)
Discussion started by: kingdbag
4 Replies

9. Shell Programming and Scripting

sftp bash script

Hello everybody! I am writing a script to connect to a sftp server from a client (both are Linux machines) and pull some files from there. The script is supposed to check if the files are already put on the server and if yes take them. If not, check again in 10 minutes, let's say. Everything... (2 Replies)
Discussion started by: abcd
2 Replies

10. Shell Programming and Scripting

Simple Bash Script

I'm sure I'm doing something wrong but as I am new to bash shell scripting I'm not sure what: Here's the code webalizer.conf is sitting in the same directory as this file which is named webalizer.sh. Can someone tell me if I've got the syntax right -- it that's correct? I'm executing the... (3 Replies)
Discussion started by: xaphalanx
3 Replies
Login or Register to Ask a Question