Trouble with $ and # in member names

Discussion of Co:Z sftp, a port of OpenSSH sftp for z/OS
Post Reply
tmkos
Posts: 2
Joined: Wed Jan 28, 2015 7:51 am

Trouble with $ and # in member names

Post by tmkos »

Hi Community!

I run into some trouble when generating PUT Statements, because some of our member names contains special characters like $ and #. The $ always leads to variable substitution in cozsftp - even in single quotes.

Normally a single qoute preserves the given string - no variable substitution by the shell:

Using CozBatch just try

STDIN:

Code: Select all

//STEP04  EXEC COZBATCH    
//STDIN   DD *             
echo PUT Member: $abc#ABC  
echo 'PUT Member: $abc#ABC'
STDOUT:

Code: Select all

PUT Member: #ABC  
PUT Member: $abc#ABC 
The second line is fine, because the single quotes keeps the string unchanged.

Using cozsftp this approach doesn't work!

STDIN:

Code: Select all

//STEP04  EXEC COZBATCH                                
//STDIN   DD *                                         
coz_bin="/opt/coz/bin"                                 
remoteuser="myuser"                                       
server="myserver"       
$coz_bin/cozsftp -b- $remoteuser§$server<<EOB          
put '//HLQ.MYPDS($abc#ABC)' '$abc#ABC'
quit                                                   
EOB                                                    
STDOUT: :!:

Code: Select all

cozsftp> put '//HLQ.MYPDS(#ABC)' '#ABC' 
The single qoute works fine to keep the # and the following characters. But the $abc was substituted by "", wich is the default value of an undefined variable. So it seems, that the cozsftp performs variable substitution on its own, because the shell itselves does not change the characters in single quotes.

By the way: The code pages are set correctly, because the content is transfered and converted corretly to the target machine.

So, how can I handle theses special names correctly? Any help is welcome!
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Re: Trouble with $ and # in member names

Post by dovetail »

When you use <<EOB to redirect stdin input to a command (like cozsftp), the z/OS UNIX shell will substitute for $variables.
See the z/OS Unix Command Reference for more details.

One way around this, to disable substitution is to put single quotes around <<'EOB', like:

$coz_bin/cozsftp -b- $remoteuser§$server<<'EOB'
put //HLQ.MYPDS($abc#ABC) $abc#ABC
quit
EOB
tmkos
Posts: 2
Joined: Wed Jan 28, 2015 7:51 am

Re: Trouble with $ and # in member names

Post by tmkos »

:D

Great!

I've tried Your solution and it works fine for me!

Thanks for Your fast response!

Tim
Post Reply