Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Windows path as argument to script called by EXEC

Status
Not open for further replies.

Calator

Programmer
Feb 12, 2001
262
0
0
AU
Could anyone advise how we can pass a Windows directory including spaces to a shell script called from exec in batch.tbl, example:
REPORT2 MYJOB EXEC -PARAM "myscript 'my\ windows\ path'"
or
REPORT2 MYJOB EXEC -PARAM 'myscript "my\ windows\ path"'

Both above aborted. The script works ok when invoked from the Unix prompt, but it aborts when invoked from exec. It appears that the escaping character "\" is not passed into the script, or other problems occur.
The script will obtain an interface file via ftp, from a Windows server.
 
I did a little test on this.

Looks like you can escape the "\" to pass a "\" through to your script:

Code:
Report1 MSR010 MSR010  -Description Table_File_Report -Report A
Report1 MSR010 EXEC    -PARAM sjwtest 'c:\\program files'

The script sjwtest looks like this:

Code:
echo $1 $2 $3 > /tmp/sjwtest.out

And the output from this script (in /tmp/sjwtest.out) looks like this:

Code:
c:\program files

Now initially, I just had this setup as echo $1 and all I got was 'c:\program'.

So, when you pass this to the shell script, it's interpreting the spaces here as parameter separators.

This is probably a good time to use the abbreviations that windows has - these remove the spaces from long directory & file names.

To see these, drop to a windows command prompt on the server you're working on. Do a "DIR /X" - this will show you the short names of the directories you'll be working on.

So, "c:\program files" will become "c:\progra~1", which would need to become "c:\\progra~1" in your script.

So, something like "c:\program files\my documents\something else" would likely become, in the batch table: 'c:\\progra~1\\mydocu~1\\someth~1' (based upon the output of DIR /X)

Hope that helps.

Steve

stephen.wales@riotinto.com
 
Steve,

Thanks for all your trouble, but it did not work for me.
And I'm afraid I was not clear enough.

Here is my script call, it works ok when invoked straight from the Unix prompt:

fp-ftp-lan get receive.001 FPT53I.TXT '/groups/flinders\ power/workers\ comp/mims/dev' corp

as it can be seen , this is a script that invokes ftp, which understands a path using forward slashes rather than the DOC syntax which requires back-slashes; I have used the backslash to "escape" the spaces within the path. So the actual DOS path is in fact:
\groups\flinders power\workers comp\mims\dev

Now, I've tried the DOS abbreviations as you smartly suggested, but for whatever reasons, they don't appear to work for me, maybe it's ftp who does not handle that well:
I have tried from the Unix prompt:

fp-ftp-lan get receive.001 FPT53I.TXT '/groups/flinde~1/worker~1/mims/dev' corp
this comes back with error from ftp:

550 /groups/flinde~1/worker~1/mims/dev: The system cannot find the file specified.

I have also tried using backslashes (4 required in my case) and I get the same error message as above.

Now if I place the call in the batch,tbl, it's entirely a new ball game:

I tried as in your example, with quotes enclosing the list of arguments:

REPORT2 FPR53I EXEC -PARAM fp-ftp-lan "get receive.001 FPT53I.TXT /groups/flinders\ power/workers\ comp/mims/dev corp"
well, this did not supply any arguments into the script, in our case the double quotes must enclose the entire string supplied into -PARAM including the script name:

REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT /groups/flinders\ power/workers\ comp/mims/dev corp"

This creates the problem you described, as the path is not seen as one argument, but as 3. So we need some delimiters to enclose the path:

REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT '/groups/flinders\ power/workers\ comp/mims/dev' corp"

For some reason, above does not even run the batch job any more;

Then I tried two single quotes around the path:

REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT ''/groups/flinders\ power/workers\ comp/mims/dev'' corp"

This worked but again the path does not appear to be treated as 1 argument.

And finally introducing the abbreviated form:
-with forward slashes:
REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT /groups/flinde~1/worker~1/mims/dev corp"

550 /groups/flinde~1/worker~1/mims/dev: The system cannot find the path specified.

and with the backslashes:

REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT \\groups\\flinde~1\\worker~1\\mims\\dev corp"

550 groupsflinde~1worker~1mimsdev: The system cannot find the file specified.

And with even more backslashes:3,4 and 5: same message as above

and with the path enclosed by double single quote:

REPORT2 FPR53I EXEC -PARAM "fp-ftp-lan get receive.001 FPT53I.TXT ''\\groups\\flinde~1\\worker~1\\mims\\dev'' corp"

550 groupsflinde~1worker~1mimsdev: The system cannot find the file specified.

It's like all backslashes get removed when the script call is placed from batch.tbl; this is back to my original problem when trying to use the backslash to escape the space character.

Any more ideas?




 
Hello,
We have ellipse 5.2.1 and are upgrading to 5.2.3.
I hope the following will help.

For example: I created a file called "post-xxx290" that contains the script in /opt/mincom/tools/bin directory on the unix box.
look like this:
#!/bin/sh
# Script name: post_xxx290
# Description: This script will take the output file from
# Micro Focus Cobol program xxx290,
# unblock it, and FTP to the LAN
#
wrk=$BEC_WORK
ext=$MIMS_JOBNUM
toll=/opt/mincom/tools/bin/
#
dd if=$wrk/xxx290.$ext of=$wrk/xxx290.OUT conv=unblock cbs=449
#
cp $wrk/xxx290.OUT $backup/xxx290.OUT.$ext
cp $wrk/xxx290.OUT $wrk/xxx290.txt
cp $wrk/xxx290.OUT $backup/xxx290.${date1-`date +"%Y%m%d%H%M%S"`}
cd /var/opt/mincom/ellipse/ellprod/work/
#ftp.sh
HOST=Test
USER=Userid
PASSWORD=password
MODE=ascii
CD="//DATA1/Department"
COMMAND="put xxx290.txt"
LOG_IN="open $HOST\n user $USER $PASSWORD\n"
echo "${LOG_IN} ${MODE}\n cd ${CD}\n ${COMMAND}" | ftp -v -n
#
rm -f $wrk/xxx290.$ext

please note that the userid and password used for ftp must have access rights for there the file is going.
also the ellipse instance userid used to run the program and script must have executable permissions on the file in /opt/mincom/tools/bin.


I then put the script name post-xxx290 in the batch.tbl file after the program.
like this
Online xxx290 xxx290 -Description xxx290_Report -Report A
Online xxx290 EXEC -Param post_xxx290 -Description Ftp_file_to_lan

I have not had any problems with doing this.

Let me know if you need more information.
thanks,
dianne001
 
Thanks Dianne,

We use similar scripting, but more complex, because it is not dedicated to one particular program in your case xxx290, but it can handle most of our ftp needs for various data extracts and interfaces.

As such, the call to our script needs to be parameterised, and one of the the arguments passed on the command line when calling the script from batch.tbl is THE PATH to the LAN directory where the file needs to go.

My problem occurs when this path includes spaces.

Now, the example you supplied has nothing even close to addresing my issue, the call to your script in batch.tbl does not pass any arguments and the path is hard-coded inside the script.

If we similarly hard-coded the path in the script we know it will work, but then we need one script for each destination being ftp-ed, and we do not wish to go down that path.

 
I have found limitations with what can be included in the batch.tbl as EXEC statements.
To get around this problem here is 2 examples of what I have done...

1) create a generic script and pass in parameters
Online MSB222 EXEC -PARAM "gcfax GORPOFA P $BEC_JOBNUM"
Online MSB284 EXEC -PARAM "gcfax GORRAFA E $BEC_JOBNUM"
Report1 GORPOF EXEC -PARAM "gcfax GORPOFA P $BEC_JOBNUM"
Report1 GORRAF EXEC -PARAM "gcfax GORRAFA E $BEC_JOBNUM"

2) create different host aliases in your /etc/hosts file and also .netrc file of the Ellipse users home directory (tru64 unix) with the ftp commands required.

Update GOBMOB EXEC -PARAM "/usr/bin/ftp ellfpm"
Update GOBTRI EXEC -PARAM "/usr/bin/ftp ellfpt"

> cat $HOME/.netrc
machine ellfpm
login mimsfpm
password password
macdef init
ascii
get mobilcrd.dat
bye

...




Drw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top