Jump to content

AlanTrewartha

Members
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

0 Neutral

About AlanTrewartha

  • Rank
    member
  1. AlanTrewartha

    getContainerStream throws error on FMS16

    Yes, I've managed to check it works on my client with v4 and v5, but NOT v5 on the server, and I know it DID work with v4 on an older (FMP11) server
  2. AlanTrewartha

    getContainerStream throws error on FMS16

    I've noticed that a client running a v4 SCriptMaster plugin works OK, so going to try that on a test server later
  3. AlanTrewartha

    getContainerStream throws error on FMS16

    Just a me too on this - exact same server config (win 2012R2, FMS 16, Master 5.09). In case anyone is still looking in and has made progress. I can't upgrade to server 17 - just yet - and wondered if anyone else had figured out what was up with fmpro.getContainerStream and other fmpro methods
  4. AlanTrewartha

    Scriptmaster + Grails + Amazon S3

    Here's a good a place as any to post some S3 scriptmaster functions I recently knocked up. You have to import a small number of JARs from the jets3t framework http://www.jets3t.org (or I compiled a fat JAR to do it in one SMLoadJar step) to satisfy the imports and dependencies. And they definitely could do with some polish and better error handling, but they just about get the basic jobs done. (awsList, awsUpload, awsUploadContainer, awsDownload) awsList will list buckets if you leave bucketName blank RegisterGroovy( "awsList( myAccessKeyID; mySecretKey; bucketName; objectPrefix)" ; "import org.jets3t.service.impl.rest.httpclient.RestS3Service;¶ import org.jets3t.service.security.AWSCredentials;¶ import org.jets3t.service.model.*;¶ ¶ try {¶ def s3 = new RestS3Service( new AWSCredentials( myAccessKeyID, mySecretKey ) );¶ def objectListString=\"\";¶ if (bucketName)¶ { // def bucket = s3.getBucket( bucketName);¶ def chunk=s3.listObjectsChunked(bucketName, objectPrefix, \"/\", 8L, \"\", true);¶ def objectList=chunk.getObjects();¶ objectListString+= chunk.getCommonPrefixes().join(\"\n\");¶ for (int o = 1; o < objectList.length; o++) {¶ objectListString+= \"\n\" + objectList[o].getKey() + \" [\" + objectList[o].getContentLength() + \" bytes]\";¶ }¶ }¶ else¶ { def bucketList = s3.listAllBuckets();¶ for (int o = 0; o < bucketList.length; o++) {¶ objectListString+= bucketList[o].name + \"\n\";¶ }¶ }¶ return objectListString.replaceAll(/(?m)^${objectPrefix}/, \"\");¶ }¶ catch(Exception e) { return e;}¶ return false;¶"; "isGui=false" ) + RegisterGroovy( "awsUpload( myAccessKeyID; mySecretKey ; bucketName; prefixKey ; pathToFile)" ; "import org.jets3t.service.impl.rest.httpclient.RestS3Service;¶ import org.jets3t.service.security.AWSCredentials;¶ import org.jets3t.service.model.*;¶ ¶ try {¶ def s3 = new RestS3Service( new AWSCredentials( myAccessKeyID, mySecretKey ) );¶ s3uploaditem= new S3Object( new File( pathToFile ) );¶ s3uploaditem.setKey(prefixKey + s3uploaditem.getKey());¶ def s3objStore = s3.putObject( bucketName , s3uploaditem );¶ return true; // or parse data from s3objStore¶ }¶ catch(Exception e) { return e;}¶ return false;¶"; "isGui=false" ) +RegisterGroovy( "awsUploadContainer( myAccessKeyID; mySecretKey ; bucketName; prefix ; containerField)" ; "import org.jets3t.service.impl.rest.httpclient.RestS3Service;¶ import org.jets3t.service.security.AWSCredentials;¶ import org.jets3t.service.model.*;¶ ¶ try {¶ def s3 = new RestS3Service( new AWSCredentials( myAccessKeyID, mySecretKey ) );¶ s3uploaditem= new S3Object( prefix, fmpro.getContainerStream( containerField ).getBytes() );¶ def s3objStore = s3.putObject( bucketName , s3uploaditem );¶ return true; // or parse data from s3objStore¶ }¶ catch(Exception e) { return e;}¶ return false;¶"; "isGui=false" ) + RegisterGroovy( "awsDownload( myAccessKeyID; mySecretKey ; bucketName; myBucketPath ; pathToFile)" ; "import org.jets3t.service.impl.rest.httpclient.RestS3Service;¶ import org.jets3t.service.security.AWSCredentials;¶ import org.jets3t.service.model.*;¶ import org.jets3t.service.utils.*;¶ import java.io.FileOutputStream;¶ ¶ try {¶ def s3 = new RestS3Service( new AWSCredentials( myAccessKeyID, mySecretKey ) );¶ def s3obj = s3.getObject( bucketName, myBucketPath);¶ downloadFile = new File(pathToFile);¶ if(downloadFile.isDirectory()) { downloadFile = new File(pathToFile + \"/\" + myBucketPath.substring(myBucketPath.lastIndexOf(\"/\") + 1 ) ) }¶ input = s3obj.getDataInputStream();¶ output = new FileOutputStream(downloadFile); int bytesRead; byte[] buffer = new byte[8 * 1024];¶ while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); }¶ output.flush();¶ return true;¶ }¶ catch(Exception e) { return e;}¶ return false;¶"; "isGui=false" )
  5. AlanTrewartha

    Groovy script to post text to an ActiveMQ JMS

    If only XSLT wasn't taken out of web publishing in FMP12 :-(
  6. AlanTrewartha

    fmresultsetjson.xsl

    Version 1.0.0

    12 downloads

    XSLT to convert Filemaker's REST web-service XML response into clean JSON https://twitter.com/alantrewartha 2017-03-06 Adapted from the original Six Fried Rice XSLT here http://sixfriedrice.com/wp/products/filemaker-to-json-converter/ Changed: * single quotes to JSON-standard double-quotes * removed "fieldDefinitions" block (personal preference) * stopped every field value being presented as an [ array ] even when not a "repeating field" * added whitespace escaping code The white-space escaping code was entirely cribbed from https://github.com/doekman/xml2json-xslt/blob/master/xml2json.xsl

    Free

  7. View File fmresultsetjson.xsl XSLT to convert Filemaker's REST web-service XML response into clean JSON https://twitter.com/alantrewartha 2017-03-06 Adapted from the original Six Fried Rice XSLT here http://sixfriedrice.com/wp/products/filemaker-to-json-converter/ Changed: * single quotes to JSON-standard double-quotes * removed "fieldDefinitions" block (personal preference) * stopped every field value being presented as an [ array ] even when not a "repeating field" * added whitespace escaping code The white-space escaping code was entirely cribbed from https://github.com/doekman/xml2json-xslt/blob/master/xml2json.xsl Submitter AlanTrewartha Submitted 03/06/2017 Category Solutions FM Version FM Version: 0  
  8. SMLoadJar the main jar you get from http://www.apache.org/dyn/closer.cgi?path=/activemq/5.10.0/apache-activemq-5.10.0-bin.tar.gz And then here's the groovy code… RegisterGroovy( "sendToJMS( qURL ; qSubject ; qMessage )" ; "import javax.jms.*;¶ import org.apache.activemq.*;¶ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(qURL);¶ Connection connection = connectionFactory.createConnection();¶ connection.start();¶ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);¶ Destination destination = session.createQueue(qSubject);¶ MessageProducer producer = session.createProducer(destination);¶ TextMessage message = session.createTextMessage(qMessage);¶ producer.send(message);¶ connection.close();¶ return true;"; "isGui=false" ) You get back '1'/true for success or 'ERROR' for a failure to post the message. Amazed about how easy that was to get done, and I'm just posting in case this is useful to anyone else. (It's entirely cribbed code from a java primer page I found online)
  9. I contacted support@360works.com and they fixed me up with a working update! Thanks very much to 360works - great service and a great product. (The other plugins too I expect!)
  10. I have discovered one thing about the errant SFTP server that might be causing the lockup. I've 7 servers and only one is causing the lock. Similarly if I try it from command line, it is the only server that *before the password prompt* asks for access to the id_dsa key of MY client i.e. the server is trying to check MY identity possibly for auto-authentication by token If you cancel this request and login with the password as normal the command line login works and you can upload normally. So it could be the plugin is just thrown into an unknown state by this response. Very much me guessing there. (And not truly understanding how SSH certificate checking *really* works)
  11. I too am having this issue - I've a process to upload to 7 SFTP servers, and one is stalling the upload during the FTPeek_Upload step. If you use a command line or UI sftp browser you can see 0 byte files of the intended upload file but the filenames prefixed with '.in.' to make them invisible. Was this issue quietly resolved to anyone's satisfaction - if so do let me know. (I've also sent a mail directly to 360 on this - I'm just covering the bases checking here with this exact same issue) Thanks for any advice.
  12. AlanTrewartha

    windows powershell

    MORE - adding the extra line in this bit of code appears to work for "true" waiting for output cases try {¶ process.getOutputStream().close();¶ if( process.waitFor() == 0 ) { //Successful¶ stdoutThread.join(); //Wait for all output to be read¶ return stdout.toString();¶ } else { //Error when running command¶ stderrThread.join(); //Wait for entire error message to be read¶ throw new RuntimeException( stderr.toString() );¶ }¶ } catch( InterruptedException e ) {¶ throw new RuntimeException("Process was interrupted; error output is: " + stderr.toString() );¶ }¶ I haven't yet tested if non powershell invoking cmds mess up with these extra commands.
  13. AlanTrewartha

    windows powershell

    (limited) SUCCESS! http://stackoverflow.com/questions/4745895/powershell-process-hanging-when-called-from-java-application suggested to me adding "process.getOutputStream().close();¶" to the registergroovy for RunShellScript might do the trick. And indeed it does, for cases where you DON'T wait for the results (the 2nd parameter is "false") the powershell process quits OK if you add an extra line like this I've not got it to work with the waiting for the result "true" option yet which I'd ideally like to do. In practice the shell is never going to take longer than a few seconds, so I can just sleep/wait before continuing what I am doing
  14. AlanTrewartha

    windows powershell

    FWIW, I'm trying RunShellScript( ""powershell.exe -ExecutionPolicy Unrestricted -File … ;"true";0) and it works (YAY), in that it runs the .ps1 file I specify, but when I run it as a schedule on the server, the schedule locks (BOO) with status "RUNNING" and the client by that schedule name persists. Previously when schedules lock like that I have to take the whole DB offline to fix that. I'm going to try "false" instead of true to see if I can work round it, and I'll post back if that works at least.
×

Important Information

By using this site, you agree to our Terms of Use.