|
Hi John,
Sigh... the article you took this from was a mistake. When I wrote it,
I did not know how to read an environment variable in an Expect script --
but, now I do :-)
So, I'm glad it's working for you. But, there's an easier way, you can
just refer to then as $env(USER) or $env(PASSWORD) directly from within
Expect, so there's no real reason to build the Expect script on-the-fly as
you're doing.
For instance, you could put the following in an IFS file:
#!/usr/local/bin/expect -f
set timeout 20
spawn sftp $env(USER)@xxx.com
expect {
default {exit 2}
"continue connecting (yes/no)?" {send "yes\n"; exp_continue}
"assword:" {send "$env(PASSWORD)\n"; exp_continue}
"sftp>"
}
send "put $env(PUTFILE)\n"
expect {
default {exit 2}
"not found" {exit 3}
"sftp>"
}
send "quit\n"
exit 0
Then you could just run that (with expect -f) from your CL program (or
whatever you're using.)
On 6/24/2014 10:36 AM, John McKee wrote:
This may help. It sends a single file. Environment variables are used.--
#!/bin/sh
build_script() {
cat <<End-of-message
#!/usr/local/bin/expect -f
set timeout 20
spawn /QOpenSys/usr/bin/sftp ${USER}@xxx.com
expect {
default {exit 2}
"Connecting to ...\r\n"
}
expect {
default {exit 3}
default {exit 3}
"password:"
}
send "${PASSWORD}\n"
expect {
default {exit 4}
"sftp>"
}
set timeout 7200
send "put ${PUTFILE}\n"
expect {
default {exit 5}
"sftp>"
}
send "quit\n"
send "quit\n"
exit 0
End-of-message
}
build_script | /usr/local/bin/expect -f -
John McKee
On Tue, Jun 24, 2014 at 10:24 AM, Jim Franz <franz9000@xxxxxxxxx> wrote:
i don't have any script yet. Other side not supplying any. This is
unattended.
Basic an edi file send, and later and edi response.
Would appreciate a script if you have it
jim
On Tue, Jun 24, 2014 at 10:09 AM, John McKee <jmmckee@xxxxxxxxxxxxxx>
wrote:
I had several sftp sessions on our i, after Scott's assistance.
Are you using an expect script?
Are you tryng to run as an unattended process?
I can send a script to you if that helps.
John McKee
On Tue, Jun 24, 2014 at 8:56 AM, Jim Franz <franz9000@xxxxxxxxx> wrote:
I have a sftp to setup (today) on i but no mention of keys in spec.
Have user/password, and this stmt "Connection SFTP (port 22)"morning.
when I try just ftp connection on port 22, get response
SSH-2.0-1.36_sshlib GlobalSCAPE
I tried to reach scottklement.com/openssh but site not responding
Our normal sftp is thru win server but tech's wife had baby this
list
Need these 3 stepslist
connect > send
connect > dir > (to a log file to determine if new file to get
connect > get
Any pointers appreciated.
Jim Franz
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxxThis is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
To post a message email: MIDRANGE-L@xxxxxxxxxxxxThis is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.