× 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.



This process involved two people on my end. Never looked hard at the code used
to actually invoke my sftp script. There was a problem with that which has
been fixed. The script is now invoked using QSH. Now, I am wondering if there
is an issue with how the PATH variable is set. When I run QP2SHELL, the PATH is
different from QSH. The PATH in QP2TERM shows multiple directories. But, the
PATH in QSH only has a single directory. Not a big issue as I put the full
path for everything in the script. But, are they supposed to be different? If
not, how do I fix - seems like they should both be using the same startup files.

A second wrinkle has emerged. The requirement is that two files be sent. So, I
modifed the expect script to look for the sftp> prompt and do the second put. The log does not show an error, but the file does not appear on the remote site
either. I have checked the path names and they are correct. When they aren't,
as they weren't earlier, sftp throws an error. No error now. But, no second
file either.

Do I need something else in the following sequence to get the second put to
work?

expect "sftp>"
send "put ${PUTFILE} \n"
expect "sftp>"
send "put ${PUTFILE2} \n"
expect "sftp>"
send "quit\n"
exit

John McKee

Quoting stenore@xxxxxxx:

I know it will be after the fact but can you pipe the ouput to a file and then read it? Below is a sample of one I have that calls the script with the pipe to a log file in the profiles home directory, you could then read through it and look for errors

shell = ' ~/.scripts/noniset.sh > '???????????????
?????????? + '~/Output/'??????????????????????????
?????????? + %trim(syshost) + '_' + %trim(sysuser)
?????????? + %char(Todaydate) + %trim('.log') ;???

QP2SHELL('/QOpensys/usr/bin/sh' + x'00'? : Shell) ;

-----Original Message-----
From: John McKee <jmmckee@xxxxxxxxxxxxxx>
To: midrange-l@xxxxxxxxxxxx
Sent: Fri, 27 Mar 2009 10:14 am
Subject: Re: sFTP - the sequel



The only authentication supported is username/password. They are unbending on
this.

I still don't know how to get the status of sftp back to CL for testing. Kind
of like poking around in the dark.

I will look at trying qsh. It is worth a shot.

John McKee

Quoting Walt Madden <walterross@xxxxxxxxx>:

John McKee wrote:
a tale of woe involving qp2shell, expect, sftp...

My observations:



It appears your only need of Expect in this scenario is to supply the ssh
password. The rest of the scenario could be accomplished with the batch
mode capability built into sftp. If your partner allows (and it would seem
strange that they would not since it means all of their clients will suffer
with the very same complexities and issues that you are) you could
authenticate with SSH Public Key Authentication and eliminate Expect from
your scenario. (If you want to learn more about Public Key Authentication,
Google "OpenSSH Public Key Authentication" to see lots of articles
describing this).



As Scott Klement mentions, if you are committed to doing this with Expect,
you'll need to put additional logic into your Expect script to detect the
sftp failure and surface that back to Expect's caller. Using sftp in batch
mode within Expect might make it easier to detect the sftp failure (by
checking sftp exit status in the Expect script) and then you just need to
get the Expect script to also return a non-zero exit status to it's caller.



I'm not certain that it is a problem, but it would make me nervous to start
all of this off with QP2SHELL. I believe you are doing exactly what Usage
Note 2 in the QP2SHELL documentation (
http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/topic/apis/qp2shell.htm

)
is trying to warn you not to do (i.e. you're running a shell script via
QP2SHELL). When QP2SHELL is used to start another shell (/usr/bin/sh in
your example) the stdin/stdout/stderr descriptors inherited by /usr/bin/sh
are the "plain" ILE descriptors fro
m the job that called QP2SHELL. Those
ILE descriptors can act in strange ways when they are fork'd (or spawn'd)
into new child jobs as your shell script and Expect will be doing. Probably
better to start this off via QSH versus QP2SHELL.


--
-----
Walt Madden
IBM i software development




--
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.





--
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.


--
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 thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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.