Yeah I am quite new to scripting but I found on our iseries that for some bizarre reason it needed a pound (£) symbol instead of ($) on variable declerations, not sure why - I'm quite new to this
It was just receiving null for the command parameters and this was the reason at the time
Hope that relates
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: 08 May 2009 21:51
To: Midrange Systems Technical Discussion
Subject: RE: QSH setting a variable
Working on my very first shell script just to help you out...
Here it is:
echo $1 
mycmd='CPYFRMIMPF FROMSTMF('${1}') TOFILE(ROB/TESTSH) RCDDLM(*CRLF)'
echo $mycmd 
system $mycmd 
It has an issue but here goes...
testshell '/rob/testsh' 
  /rob/testsh 
  CPYFRMIMPF FROMSTMF(/rob/testsh) TOFILE(ROB/TESTSH) RCDDLM(*CRLF) 
  CPD0104:  Expression not allowed for parameter FROMSTMF. 
  CPF0001:  Error found on CPYFRMIMPF command. 
  CPC2206:  Ownership of object QZSHSYSTEM in QTEMP type *USRSPC changed.
  $ 
Note:  I do not use eval mycmd.  I just use mycmd.
The bug now is how do I get the apostrophes around the parameter $1 
without turning it into a comment.
This works:
echo $1 
mycmd='CPYFRMIMPF FROMSTMF(''"'${1}'"'') TOFILE(ROB/TESTSH) RCDDLM(*CRLF)'
echo $mycmd 
system $mycmd 
testshell /rob/testsh 
  /rob/testsh 
  CPYFRMIMPF FROMSTMF("/rob/testsh") TOFILE(ROB/TESTSH) RCDDLM(*CRLF) 
  CPC2206:  Ownership of object QCPIMTEMPS in QTEMP type *USRSPC changed. 
  CPC2206:  Ownership of object QACPTEMP01 in QTEMP type *USRSPC changed. 
  CPC2206:  Ownership of object QCFT209659 in QTEMP type *USRSPC changed. 
  CPC2206:  Ownership of object Q2F9FF02 in QTEMP type *FILE changed. 
  CPC2959:  2 records copied to member TESTSH. 
  CPC2206:  Ownership of object QZSHSYSTEM in QTEMP type *USRSPC changed. 
  $ 
Contents of /rob/testsh
 ************Beginning of data
A,B 
C,D 
 ************End of Data******
Contents of ROB/TESTSH table
....+....1
COL1  COL2
 A     B 
 C     D 
******** 
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.