Jump to content
Ketarin forum

Triggering Commands Before Downloading


Recommended Posts

I have batch script set to run wget to download an application, but I can't get it to trigger on change. I've tried leaving in a value for the URL field, but it errors out. I've removed all data from the URL field and it now updates the version properly, but doesn't trigger the batch script to run. I know the batch script works as I can go into Edit-> Commands Tab -> Run and it downloads the file. I thought from reading the wiki that an external program could be used to download an application, but I'm not clear on how to get the command to trigger. Can someone help clarify how and when those commands are trigger?

 

Thanks,

Beavel

 

*Sidenote: I went to wget because the application I am downloading requires a cookie to download, and needed to save and load it through wget.

Link to post
Share on other sites
  • 2 months later...

I'm just getting back to this issue as the application I need it for has updated, and the command did not run. I'm still not clear on when my batch script should trigger and run. I have an empty URL field which Ketarin complains about when I save the application. The warning Ketarin provides states that this application won't be downloaded, which I think is my problem. However, if I put anything in the URL field, Ketarin fails to detect a version change and complains it can't download the file because it is not of a binary file type. What should be placed in the Download Sources URL field so that the batch script runs, and Ketarin doesn't complain about the file not being binary?

 

Below is my script in case there is something problematic with it, but it seems to work fine when I manually run it.

 

start "" /wait wget --content-disposition --spider --save-cookies="{cookiesFile}" {downloadURL}
start "" /wait wget --content-disposition --output-document="{appdir}{outputFilename}" --load-cookies="{cookiesFile}" {downloadURL}
exit 3

Link to post
Share on other sites
  • 2 weeks later...

Well... this topic has become academic for me now. The site has updated in the last two weeks so cookies are no longer needed and I can reference the download directly.

 

With that said, I'm still interested in why it wasn't working. When I tried putting a valid URL in, Ketarin would throws an error that the file doesn't exist. If I put in an invalid URL it would throw an error that the URL isn't valid. I'm using Ketarin 1.6.0.434.

 

Here is my app profile if it helps:

 

<?xml version='1.0' encoding='utf-8'?>
<Jobs>
 <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Guid="c340a239-ccd3-42fc-aadc-5b1bde938291">
<WebsiteUrl />
<UserAgent />
<UserNotes />
<LastFileSize>666540</LastFileSize>
<LastFileDate>2011-08-20T09:26:14.46045</LastFileDate>
<IgnoreFileInformation>false</IgnoreFileInformation>
<DownloadBeta>Default</DownloadBeta>
<DownloadDate xsi:nil="true" />
<CheckForUpdatesOnly>false</CheckForUpdatesOnly>
<VariableChangeIndicator>version</VariableChangeIndicator>
<CanBeShared>true</CanBeShared>
<ShareApplication>false</ShareApplication>
<ExclusiveDownload>false</ExclusiveDownload>
<HttpReferer />
<SetupInstructions />
<Variables>
  <item>
	<key>
	  <string>version</string>
	</key>
	<value>
	  <UrlVariable>
		<RegexRightToLeft>false</RegexRightToLeft>
		<VariableType>RegularExpression</VariableType>
		<Regex>(?<=<A HREF).*?((\d[.]){1,3}\d+)(?></A>)</Regex>
		<Url>http://hashcat.net/hashcat/</Url>
		<Name>version</Name>
	  </UrlVariable>
	</value>
  </item>
  <item>
	<key>
	  <string>cookiesFile</string>
	</key>
	<value>
	  <UrlVariable>
		<RegexRightToLeft>false</RegexRightToLeft>
		<VariableType>Textual</VariableType>
		<Regex />
		<TextualContent>{appdir}cookies.txt</TextualContent>
		<Name>cookiesFile</Name>
	  </UrlVariable>
	</value>
  </item>
  <item>
	<key>
	  <string>downloadURL</string>
	</key>
	<value>
	  <UrlVariable>
		<RegexRightToLeft>false</RegexRightToLeft>
		<VariableType>Textual</VariableType>
		<Regex />
		<TextualContent>http://hashcat.net/files/download.php?proj={appname}</TextualContent>
		<Name>downloadURL</Name>
	  </UrlVariable>
	</value>
  </item>
  <item>
	<key>
	  <string>appdir</string>
	</key>
	<value>
	  <UrlVariable>
		<RegexRightToLeft>false</RegexRightToLeft>
		<VariableType>Textual</VariableType>
		<Regex />
		<TextualContent>{archive}\Hashcat\{appname}\</TextualContent>
		<Name>appdir</Name>
	  </UrlVariable>
	</value>
  </item>
  <item>
	<key>
	  <string>outputFilename</string>
	</key>
	<value>
	  <UrlVariable>
		<RegexRightToLeft>false</RegexRightToLeft>
		<VariableType>Textual</VariableType>
		<Regex />
		<TextualContent>{appname}-{version}.7z</TextualContent>
		<Name>outputFilename</Name>
	  </UrlVariable>
	</value>
  </item>
</Variables>
<ExecuteCommand />
<ExecutePreCommand>REM start "" /wait
start "" /wait wget --content-disposition --spider --save-cookies="{cookiesFile}" {downloadURL}
start "" /wait wget --content-disposition --output-document="{appdir}{outputFilename}" --load-cookies="{cookiesFile}" {downloadURL}
exit 3</ExecutePreCommand>
<ExecuteCommandType>Batch</ExecuteCommandType>
<ExecutePreCommandType>Batch</ExecutePreCommandType>
<Category>InfoSec</Category>
<SourceType>FixedUrl</SourceType>
<PreviousLocation>F:\Archive\Hashcat\hashcat\hashcat-0.37.7z</PreviousLocation>
<DeletePreviousFile>false</DeletePreviousFile>
<Enabled>true</Enabled>
<FileHippoId />
<LastUpdated>2011-08-20T09:26:14.46045</LastUpdated>
<TargetPath>{archive}\Hashcat\{appname}\</TargetPath>
<FixedDownloadUrl>{downloadURL}</FixedDownloadUrl>
<Name>hashcat</Name>
 </ApplicationJob>
</Jobs>

 

Another interesting thing is that when I updated the URL to be correct for the new site, my script fired, downloaded the file, and then Ketarin downloaded it right after. It seems that it ignored the exit 3.

Link to post
Share on other sites
  • 3 years later...

Putting some text in the download url field doesn't work for me at all.

For debugging I added a plain

echo xxxx >T:\x.txt

into the pre-update commands section.

Guess what? No x.txt file is generated. The commands (including wget and exit) just aren't triggered at all.

Link to post
Share on other sites

echo xxxx >T:\x.txt

into the pre-update commands section.

Guess what? No x.txt file is generated. The commands (including wget and exit) just aren't triggered at all.

 

This should work:

echo xxxx >> D:\x.txt

Regarding your command set (wget/exit/etc) please add some more details.

Link to post
Share on other sites

Ok, changed:

echo TEST {preupdate-url} >> T:\xx.txt
"\PortableApps\WinWGetPortable\App\winwget\wget\wget.exe" "http://www.acetext.com/cgi-bin/download" -P "\Downloads" -c --post-data="lang=en&app=act&email={email}&id={id}" --output-document=\Installer\JGSoft\{file:filename} && exit 3
exit 2

Just for completeness sake...

Ok, the WGet download parameters are working perfectly, as I tried them using WGet / WinWGet manually and the download succeded perfectly.

Email and id were replaced by me because they are my license data I need to submit. They are plain text within Ketarin though variables should work, too.

 

No text file xx.txt is generated on calling update or force update. Maybe because Ketarin still for some reason thinks the (not existing aka deleted) file I downloaded earlier is still valid and current.

 

 

EDIT:

Actually I wouldn't mind if you cross check my main thread about my download problem: (Link)

 

Neither setting a fake download uri nor leaving it empty helps.

Setting or removing my update variable doesn't help either.

Not even faking a new version number (aka setting a text variable as update variable and adding a plain text string faking a new version number).

Link to post
Share on other sites
  • 6 years later...

I know this is years late, but I was looking for something else and saw that one of the issues in this wasn't addressed.

The problem with your troubleshooting line is most likely that you didn't quote the URL. This means that your script will crash before it actually echoes anything to the file if there's an ampersand (&) or certain other characters in the {preupdate-url} variable. Try this instead:

echo TEST "{preupdate-url}" >> T:\xx.txt
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.