Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
CMD question
 Login/Join
 
Platinum Member
posted
This is a follow up to a previous question that I had. The original question was how to run a .VBS or .BAT script from a Webfocus program. Well, I have fiddled around with all kinds of different code based on the original answer to my question. This was the original answer:

Mark, the way i do it is to write a fex
that, itself, runs the script
i often just write the script in the fex.
For example

CMD COPY \\theirserver\dir\*.jpg \\myserver\dir\*.jpg

copies all my pictures
Some installations can use DOS command,
i need to use the CMD syntax.
Your fex , scheduled by Caster, would then run whatever
DOS activities you might need.
If your script exists, just filedef it and run it;

FILEDEF MYSCRIPT DISK D:\....\MYSCRIPT.BAT
CMD MYSCRIPT.BAT

To write a script inside a fex, something like this:

FILEDEF MYSCRIPT DISK MYSCRIPT.BAT
-RUN
-WRITE MYSCRIPT first line
-WRITE MYSCRIPT next line
...etc
CMD MYSCRIPT.BAT

I have tried all of these suggestions, to no avail. The major problem that I'm having is with the CMD MYSCRIPT.BAT line. I've even gotten so far as to get WEBFOCUS to write the script for me using this code:

FILEDEF MYSCRIPT DISK \\CLEVELANDPOINT\IBI\APPS\BASEAPP\MYSCRIPT.BAT
-*FILEDEF MYSCRIPT DISK MYSCRIPT.BAT
-RUN
-WRITE MYSCRIPT OPTION EXPLICIT
-WRITE MYSCRIPT DIM OBJACCESS
-WRITE MYSCRIPT DIM STRPATH
-WRITE MYSCRIPT DIM STRQUERY
-*'Dim WshNetwork, PrinterPath, PrinterDriver
-WRITE MYSCRIPT STRPATH = "\\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.MDB"
-WRITE MYSCRIPT STRQUERY = "UPLOAD"
-WRITE MYSCRIPT SET OBJACCESS = CREATEOBJECT("ACCESS.APPLICATION")
-* ' Open the desired database
-WRITE MYSCRIPT OBJACCESS.OPENCURRENTDATABASE(STRPATH)
-WRITE MYSCRIPT OBJACCESS.DOCMD.OPENQUERY STRQUERY
-WRITE MYSCRIPT OBJACCESS.CLOSECURRENTDATABASE
-WRITE MYSCRIPT OBJACCESS.QUIT
-WRITE MYSCRIPT SET OBJACCESS = NOTHING
CMD MYSCRIPT.BAT

But as soon as it gets to the CMD line, I keep getting the error:
'MYSCRIPT.BAT' is not recognized as an internal or external command,
operable program or batch file.

Any and all suggestions are very welcome. Thank you!


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Master
posted Hide Post
Change
CMD MYSCRIPT.BAT

to

CMD \\CLEVELANDPOINT\IBI\APPS\BASEAPP\MYSCRIPT.BAT




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Platinum Member
posted Hide Post
quote:
CMD \\CLEVELANDPOINT\IBI\APPS\BASEAPP\MYSCRIPT.BAT


I end up with this error when I do that:

D:\ibi\srv71\wfs\edatemp\ts000377>OPTION EXPLICIT
'OPTION' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>DIM OBJACCESS
'DIM' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>DIM STRPATH
'DIM' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>DIM STRQUERY
'DIM' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>STRPATH = "\\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.MDB"
'STRPATH' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>STRQUERY = "UPLOAD"
'STRQUERY' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>SET OBJACCESS = CREATEOBJECT("ACCESS.APPLICATION")
D:\ibi\srv71\wfs\edatemp\ts000377>OBJACCESS.OPENCURRENTDATABASE(STRPATH)
'OBJACCESS.OPENCURRENTDATABASE' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>OBJACCESS.DOCMD.OPENQUERY STRQUERY
'OBJACCESS.DOCMD.OPENQUERY' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>OBJACCESS.CLOSECURRENTDATABASE
'OBJACCESS.CLOSECURRENTDATABASE' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>OBJACCESS.QUIT
'OBJACCESS.QUIT' is not recognized as an internal or external command,
operable program or batch file.
D:\ibi\srv71\wfs\edatemp\ts000377>SET OBJACCESS = NOTHING


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Platinum Member
posted Hide Post
Also, I don't know if this is going to make a difference, but each of the errors starts with a D: label, while the label that my database is on is I: .


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Master
posted Hide Post
Mark lets see of executing OS level commands work by them self. create a focexec and add the following code to it and run it.

DOS DIR

that's it, run it and see what happens this will tell you if OS level commands are enable and what the current working directory is. you should get a normal DIR listing

Scott




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Master
posted Hide Post
Sorry, It is working

the errors you are getting a valid OS level errors the OPTION is not a OS level command or a program in the current path, same for the other errors.




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Platinum Member
posted Hide Post
Thanks Texas. Yes, I went to the C:> prompt and tried to run the .BAT file and got the same error messages just a minute ago. I changed the .BAT to a .VBS and ran if from the C:> prompt and it went fine. So, in my FEX, I changed every .BAT to a .VBS and am running it. It is taking forever though. Way too long. The script runs from the C:> prompt in seconds. Thoughts?


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Master
posted Hide Post
Sorry, no suggestions I thought it would run just as fast.




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
mark, try filedeffing your script to your agent
here's how i do my ftp calls:
FILEDEF CHFTP DISK GET.FTP
-RUN

-WRITE CHFTP open ftp.mysite.com
-* my userid goes here
-WRITE CHFTP userid
-* my password goes here
-WRITE CHFTP password
-WRITE CHFTP ascii
-* change dir on ftp site
-WRITE CHFTP cd mydirname
-*local change directoris
-WRITE CHFTP lcd \
-WRITE CHFTP lcd mysubdirname
-WRITE CHFTP lcd mysubsubdirname
-* get files from ftp
-WRITE CHFTP get filenameonftpsite
-WRITE CHFTP get anotherfilenameonftpsite

-WRITE CHFTP close
-WRITE CHFTP quit
-RUN

DOS ftp -i -s:GET.FTP




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
I'm sorry Susannah. I'm having a tough time following your code. Could you maybe explain the process that this code is going through, so that I try to write it correctly? Thanks!


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Expert
posted Hide Post
Mark,

The code that Susannah has given is a DOS FTP process. To best understand this open a command prompt in Windowse and then type FTP. Once you are in FTP you can issue a ? to list the commands available, you can get further info e.g. typing ? lcd will give you info on what lcd is used for - in this case change local directory (on the PC).

Type quit into the FTP prompt to exit FTP.

T

BTW : You might also require a
-WRITE CHFTP prompt
in there to negate the prompting of normal FTP



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
yeah, like T says, its just an example of filedeffing a script to my agent.
FILEDEF CHFTP DISK GET.FTP
see how there is no drive letter or dir name in front of my filename GET.FTP ? that means its getting written directly to my agent directory.
then all the -WRITE commands are writing to that text file , the one named CHFTP
then when i've finished writing my little file, i then issue the commands to execute it.
DOS ftp -i -s:GET.FTP
It doesn't much matter what the commands are that i write to my little ftp file, its not necessary to follow the logic there...just get the idea that i'm writing a file to my agent and then executing it. the agent is always on the top of the path...so you'll always be able to locate your script.
then when my entire fex has finished, the agent dies, little script file and all.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
OK, thanks Tony and Susannah. I'm going to give it a shot. Thanks for the help, I'll let you know how it goes.


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Platinum Member
posted Hide Post
So basically, I can have anything in the -WRITE lines of the program, but the important thing is that FILEDEF CHFTP DISK GET.FTP then the DOS ftp -i -s:GET.FTP


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Expert
posted Hide Post
Mark,

Anything providing it's correct syntax - we don't want a foul up now!?!

The command line that Susannah has given you negates having to put all the FTP commands within the .bat file. The -s means "use this file for the FTP commands" which is always followed by a colon and the file name with the relative or complete path. I tend to pipe the output to a log file so that I have an audit trail of what went on. If you want to add the pipe to a file then don't forget to filedef it to a location that isn't wiped on completion of the agents task.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Platinum Member
posted Hide Post
Hey,
I'm running into the same problem as before where it is taking forever to run. Here is the code that I'm running:
FILEDEF CHFTP DISK GET.FTP
-RUN
-WRITE CHFTP OPTION EXPLICIT
-WRITE CHFTP DIM OBJACCESS
-WRITE CHFTP DIM STRPATH
-WRITE CHFTP DIM STRQUERY
-*'Dim WshNetwork, PrinterPath, PrinterDriver
-WRITE CHFTP STRPATH = "\\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.MDB"
-WRITE CHFTP STRQUERY = "UPLOAD"
-WRITE CHFTP SET OBJACCESS = CREATEOBJECT("ACCESS.APPLICATION")
-* ' Open the desired database
-WRITE CHFTP OBJACCESS.OPENCURRENTDATABASE(STRPATH)
-WRITE CHFTP OBJACCESS.DOCMD.OPENQUERY STRQUERY
-WRITE CHFTP OBJACCESS.CLOSECURRENTDATABASE
-WRITE CHFTP OBJACCESS.QUIT
-WRITE CHFTP SET OBJACCESS = NOTHING
-RUN
DOS ftp -i -s:GET.FTP

Can y'all see anything in my code that would cause it to take so long? Thanks!

Actually, last week when Texas and I were communicating, the job that was taking forever finally did finish in just under 24 hours. For this project, though, that is going to be unacceptable because this needs to run every day.


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
Expert
posted Hide Post
Mark,

The example given was for running FTP, you are trying to create vbs(?) so not quite what you would need.

I think that, somehow, along the line we have strayed away from exactly what you are trying to do, so let's take a step back.

Firstly, what are you trying to do?

answer: Run a VB script from a DOS bat job.

How do you achieve that?

answer: Not quite the way you are trying to do it.

How can you run the VBS file?

answer: You need to be in the directory where your script resides or use a full path reference to it and ensure that the correct file extension is applied.

TexasStingray had the answer to your dilemma right at the beginning but we all missed the important part. You are writing to, and trying to execute, a BAT file and not a VBS file.

So change your original to -
FILEDEF MYSCRIPT DISK \\CLEVELANDPOINT\IBI\APPS\BASEAPP\MYSCRIPT.VBS
-RUN
-WRITE MYSCRIPT OPTION EXPLICIT
-WRITE MYSCRIPT DIM OBJACCESS
-WRITE MYSCRIPT DIM STRPATH
-WRITE MYSCRIPT DIM STRQUERY
-*'Dim WshNetwork, PrinterPath, PrinterDriver
-WRITE MYSCRIPT STRPATH = "\\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.MDB"
-WRITE MYSCRIPT STRQUERY = "UPLOAD"
-WRITE MYSCRIPT SET OBJACCESS = CREATEOBJECT("ACCESS.APPLICATION")
-* ' Open the desired database
-WRITE MYSCRIPT OBJACCESS.OPENCURRENTDATABASE(STRPATH)
-WRITE MYSCRIPT OBJACCESS.DOCMD.OPENQUERY STRQUERY
-WRITE MYSCRIPT OBJACCESS.CLOSECURRENTDATABASE
-WRITE MYSCRIPT OBJACCESS.QUIT
-WRITE MYSCRIPT SET OBJACCESS = NOTHING
CMD \\CLEVELANDPOINT\IBI\APPS\BASEAPP\MYSCRIPT.VBS
and, hopefully, you'll be cooking.

In our defence I would add that this is not strictly a WebFOCUS problem but a DOS / VBS problem where the files just happen to be written using WebFOCUS. Big Grin

Good luck

T

btw: I've not looked at the content of your VBS script at all so I cannot vouch for whether it is correct syntax or not!! The "cop out" clause. Wink



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Platinum Member
posted Hide Post
OK, well, after going back over stuff from months ago, I found a line of code that is at least moving me in the right direction. However, there is another problem. The script works fine when I run it from windows, however when I try to run this line of code from Webfocus:

CMD CSCRIPT.EXE \\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.VBS

I get the error:

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
\\CLEVELANDPOINT\IBI\APPS\BASEAPP\TEST.VBS(12, 9) Microsoft VBScript runtime error: ActiveX component can't create object: 'Access.Application'

I know that the error is a Microsoft VBScript related error, but I don't get this error unless I run it from a fex. Any ideas? Thanks for all of your help.


Windows version 768
 
Posts: 215 | Registered: March 16, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders