Invalid flag -?

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
cvs
Posts: 7
Joined: Mon Jan 16, 2012 3:17 pm

Invalid flag -?

Post by cvs »

We had a production failure on the mainframe the other day attempting to retrieve a file from a windows server. Listed below is our code and the display with the error. It appears to me that the failure was due to a file name starting with a dash "-". We receive numerous files from outside the company, and we build our file retrieval commands thru a Cobol batch program. Is dash a valid file name? If so, is there a solution to get around this error?

sFTP Retrieve Commands

Code

remoteuser="<user_name>"
mainframeuser="<user_name>"
remotedir="TPMS/Remittance/common/835/$RPID"
localfile="//DD:UPLOAD"
remotefile="$INFILE1"
server=$DSERVER
servercp="ISO8859-1"
export PASSWD_DSN='SYS3.OMVS.SFTP.PARMS('$mainframeuser')'
export SSH_ASKPASS=read_passwd_dsn.sh
export DISPLAY=none
ssh_opts="-oBatchMode=no"
ssh_opts="$ssh_opts -oConnectTimeout=60"
ssh_opts="$ssh_opts -oServerAliveInterval=60"
ssh_opts="$ssh_opts -oStrictHostKeyChecking=no"
ssh_opts="$ssh_opts -oPreferredAuthentications=password"
ssh_opts="$ssh_opts -oPort=22"
$coz_bin/cozsftp $ssh_opts -b- $remoteuser@$server <<EOB
lzopts mode=text,linerule=crlf,servercp=$servercp

cd $remotedir
pwd
get "$remotefile" $localfile
EOB


Error Messages

Co:Z cozsftp version: 1.7.5 (5.0p1) 2010-12-13
Copyright (C) Dovetailed Technologies, LLC. 2008. All rights reserved.
fromdsn(SYS3.OMVS.SFTP.PARMS(TPSFTP))_ON_]: 1 records/80 bytes read; 9 bytes wrritten in 0 milliseconds.
_O30.733_] get: Invalid flag -?
cozsftp> lzopts mode=text,linerule=crlf,servercp=ISO8859-1
linerule=crlf mode=text servercp=ISO8859-1
cozsftp>
cozsftp> cd TPMS/Remittance/common/835/10508_RP
cozsftp> pwd
Remote working directory: /CVSCIFSP014 Prod/MIS/Tpftp/TPMS/Remittance/common/835/10508_RPcozsftp> get "-WVSUBID02951-20140107-19270397-005010X221A1 (102).dat" //DD:UPLOAD
CoZBatch_ON_]: Copyright (C) 2005-2009 Dovetailed Technologies LLC. All rights reserved.
CoZBatch_ON_]: version 1.7.5 2010-12-13
CoZBatch_OI_]: executing progname=login-shell="-/bin/sh"
CoZBatch_OI_]: returning rc=exitcode=1
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Invalid flag -?

Post by dovetail »

The problem seems to be that the $INFILE variable has the value:

-WVSUBID02951-20140107-19270397-005010X221A1 (102).dat

This causes problems, since the sftp "get" command assumes that the name starting with a dash is an "option" and not a file name.

Is this the correct remote file name?

If so, then one workaround would be to insert single quotes around name of the file in the get command, like this:


get "'$remotefile'" $localfile

that is, single quotes inside of double quotes). In the z/OS Unix shell, the outer double quotes will mean that the inner single quotes will be literal rather than quotes. After the shell process this line and substitutes variables, the cozsftp command will see something like this:

get '-WVSUBID02951-20140107-19270397-005010X221A1 (102).dat' //DD:UPLOAD
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Invalid flag -?

Post by dovetail »

Sorry, that doesn't work either :-)

Try this:

get -- "$remotefile" $localfile

i.e. go back to just double-quotes, but add a double-dash argument, which means "there are no more options".
This causes the remotefile name to be treated as a file name, even if it starts with a dash, and not a -option
sajjad321
Posts: 1
Joined: Mon Dec 22, 2014 2:20 pm

Re: Invalid flag -?

Post by sajjad321 »

This is probably documented somewhere, but I just wanted to know which release of Co:Z SFTP supports z/OS V2.1?
You can easily check out our best quality CCNA brain dumps exam dumps testking.biz - 220-802 brain dumps you well for the real sterling You can also get success in real exam of www.muih.edu
Post Reply