Session Variables Not Getting Passed
Hi-
I am a newbie, but I have this working pretty much as I want to:
I have a script called "run" that I invoke from the commandline:
Set RunnableScrapingSession = CreateBean( "com.screenscraper.scraper.RunnableScrapingSession", "test" )
Call RunnableScrapingSession.SetVariable ("TestVar","Val")
Call RunnableScrapingSession.Scrape()
It invokes the session test and runs it. In "test" I have other scripts to pull info and put them in a database. This all works. However, I cannot pass the variable TestVar from the "run" script - I try session.getVariable("TestVar") and it is always null.
What gives?
TIA
Souverain
Session Variables Not Getting Passed
Souverain,
I apologize for that. We exported from a newer, alpha version and I didn't test the import on 3.0 which is what you have. You're ok staying at 3.0 as basic edition. I have created a new example scraping session that should import without error. Again, please use the approach contained therein to modify your own session.
http://www.screen-scraper.com/xfer/vbscript_cmd-line2.zip
If you have any further issues please let us know.
Thanks,
Scott
Session Variables Not Getting Passed
Thanks for that.
The script imports but the scraping session file fails with a version complaint: "Sorry the Import failed. This could be because the file is corrupted or it corresponds to a higher version of screen-scaper" I am running the basic version from your site as of last week and also tried to re-install with a new version I downloaded today.
This could be my problem. What version should I be at to get this working with the script you sent?
Thanks
Session Variables Not Getting Passed
souverain,
You definitively need to use the params object to access the variable passed from the command line. For a working example that utilizes each of the elements you described please download the zip file below.
Please try the session using the support file first. If it does not work for you please let us know. If it does please use it as an example to modify your own session.
http://www.screen-scraper.com/xfer/vbscript_cmd-line.zip
You do not need the professional edition to do this.
Thanks,
Scott
Session Variables Not Getting Passed
Scott--
Thanks for the response.
I already read those two links (until I turned blue) but it is still not working so I must be missing something.
I want to be able to
(1) pass variables from the DOS commandline to the script - using the -p switch. I used the params.get() method to store it in the session, but this did not work (in the example I sent, I simplified it by just setting a static variable TestVar
(2) pass the variable from the invoked script to another script I use to extract data.
So the sequence is:
DOS(set var) -> First Script with RunnableScrapingSession (store var in session) -> Second data extraction script (get var from session)
Also: I am using basic - do I need to purchase Professional Edition to pass variables as indicated above?
Session Variables Not Getting Passed
souverain,
The way you pass variables to a scraping session that is being instantiated from an outside source (like via the command-line) requires a different approach than one you would take when a session is already running.
The documentation on passing variables within a command-line invoked from a batch file or shell script can be found here.
http://www.screen-scraper.com/support/docs/invoking_screenscraper_from_the_command_line.php
I recommend you also have a look at the additional controls available to the RunnableScrapingSession class on our API page.
http://www.screen-scraper.com/support/docs/api_documentation.php
Please let us know if you have additional questions.
Thanks,
Scott