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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-17-2016, 09:18 AM
|
#1
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Rep: 
|
SFTP not wokring
Yesterday I ran several times the sftp command with no problems. I created a bash script to run the sftp command automagically and it ran with no errors, but the results was not what I was expecting. Well now today I take my computer out of hibernation and run the script, giving the sftp command doesn't work??????? I ran the same line of code in the command line with no problems. Copied and pasted it from the command line to my script. Ran it. Doesn't run. I take the simple line out, runs fine. WEIRD!!!
This is the line:
sftp username@hostname
Now it only works when I type it in and press enter.
Any help is HIGHLY appreciated!!!!
|
|
|
11-17-2016, 09:29 AM
|
#2
|
Moderator
Registered: Aug 2002
Posts: 26,522
|
What are the error messages if any?
You can add set -xv to the script (below #!/..) to enable debugging.
|
|
|
11-17-2016, 09:42 AM
|
#3
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep: 
|
Running the script from Oracle EDQ, on error is when I run it from EDQ BUT if I comment out the line, the script works fine. Weird. Ill use your advice and see what comes up. Thank you for your help!!!!
|
|
|
11-17-2016, 09:45 AM
|
#4
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep: 
|
Just ran it, in EDQ it gave an error but how can I see this error in the command line?
|
|
|
11-17-2016, 09:48 AM
|
#5
|
Moderator
Registered: Aug 2002
Posts: 26,522
|
Not familiar with EDQ. What happens when you run it from the terminal window?
|
|
|
11-17-2016, 10:12 AM
|
#6
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep: 
|
From terminal it works fine, but when I run it from within EDQ, it doesn't work. Strange cause it was all working fine yesterday. If I comment out this line, it works fine:
sftp username@hostname
Can even access it from WinSCP just fine
|
|
|
11-17-2016, 10:25 PM
|
#7
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,426
|
You need to find a way to get 'EDQ' to o/p both stdout and stderr to the screen and/or a file, so we can debug it.
|
|
|
11-18-2016, 07:40 AM
|
#8
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep: 
|
I should put things his way instead of including EDQ......I can execute sftp commands in the command line but not in a BASH script. I haven't the slightest idea what is going on because the previous day it was working just fine.
|
|
|
11-20-2016, 11:12 PM
|
#9
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,426
|
Show us your code, both inside and outside a shell script. Also, as above, try with 'set -vx' so we can get more info.
|
|
|
11-21-2016, 02:39 PM
|
#10
|
Member
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310
Original Poster
Rep: 
|
I have actually installed the package expect and my issue has been resolved. Not the best because it it unsecure, but it's a short term solution. Here is the code:
expect -c "
spawn sftp username@hostname
expect "assword"
send "password is here\r"
expect "sftp>"
send "cd /folder to place file\r"
expect "sftp>"
send "put *.DAT\r"
expect "sftp>"
send "exit\r"
interact "
You might not need all of the lines but I needed to do certain things. Hope this helps!
|
|
|
All times are GMT -5. The time now is 04:04 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|