× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi

I have changed my scritp in:



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

set REMOTE_DIR "/cert_xxxx_name/in"

spawn sftp cert_xxxx_name@xxxxxxxxxxxxx

expect "Password:"

send "mypsw\n"

# position

send "cd $REMOTE_DIR\r"

expect "sftp>"

send "pwd \r"

expect "sftp>"

# List the directory

send "ls -la\r"

expect "sftp>"

# Exit SFTP

send "bye\r"

expect eof



this what i see in console



Connected to 111.22.333.xx.


sftp> pwd


Remote working directory: /


sftp> ls -la


drwxr-xr-x 3 root root 1 Jan 16 2024 .


drwxr-xr-x 3 root root 1 Jan 16 2024 ..


drwxrwxrwx 5 1013 1014 3 Jan 16 2024 cert_xxxx_name

sftp> bye


$



Why i din?t see anything about the line relative to "cd $REMOTE_DIR\r" ??
possible that directory don?t exist ??

Any suggestion ?

Thanks











Da: gio.cot <gio.cot@xxxxxxxxxxx>
Inviato: lunedì 30 marzo 2026 17:17
A: 'Midrange Systems Technical Discussion' <midrange-l@xxxxxxxxxxxxxxxxxx>
Oggetto: How to list a directory with expect via sftp



Hi all

I?m tryto put some file in folder SFTP Server; i would need to test if the
transfer is gone ok.

I was thinking to display directory content but i have problem; i have tried
with

expect "sftp>"

send "ls -l \\r <file://r> "

but i receive ?write() failed to write anything - will sleep(1) and
retry...?



if i try to connect to server via QP2TERM , i receive ?Permission denied,
please try again.?



How can i get this info ??



Or is there anyway after put, to show a log that say xxxx byte transfered ?






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.