Page 1 of 1

Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 3:15 am
by actionHero
I have this script that is injecting a job based on two arguments that I will enter in the script. The windows version works great. The Mac version will inject the file if found, but if not found it just sits in limbo. Almost like am creating the file so it thinks that it's there but really isn't... odd.

function jobArrived( s : Switch, job : Job )
{
var arc1 = s.getPropertyValue("Arc1"); //get value from arg

var ext = s.getPropertyValue("Ext"); //get value from arg

var name = job.getNameProper(); //get the base name

var theDestPath = job.createPathWithName(job.getNameProper(), false) + "." + ext; // create a temp spot to copy

var arcjob = arc1 + "/" + name + "." + ext ; //find archived job (i changed the directory identifier for the Mac.)

s.log(2, "source "+ theDestPath);
s.log(2, "arcjob "+ arcjob);
s.log(2, "arcjob "+ arc1);
var success = s.copy( arcjob, theDestPath); //copy from archive to temp folder
if(success == true){

job.sendToData(1, theDestPath ); //send temp folder to next pass data connection
job.sendToNull(job.getPath()); // delete input job
} else {

job.sendToData(3, job.getPath() ); //send original XML to failed field.
}
}

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 3:32 pm
by gabrielp
Perhaps it's because the directory separators are different between windows and mac?

Try this function:

Code: Select all

// Determine directory seperator
var getDirectorySeperator = function( s : Switch ){
    var directorySeperator;
    if(s.isMac()){
        directorySeperator = '/';
    } else {
        directorySeperator = '\\'
    }

    return directorySeperator;
};

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 3:43 pm
by actionHero
Thanks for your reply.

I've added that option and no such luck. When I do a s.log() and get the "type of" success, it returns as undefined. So then it can't enter the if/else statement.

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:02 pm
by cstevens
This line doesn't seem right to me:

Code: Select all

var theDestPath = job.createPathWithName(job.getNameProper(), false) + "." + ext; // create a temp spot to copy
You're creating a temp location and then adding an extension to the variable that references the location, so when you send files to that location it's not the actual location you created.

I think what you want is:

Code: Select all

var theDestPath = job.createPathWithName(job.getNameProper() + "." + ext, false); // create a temp spot to copy
not sure why this is working on Windows, maybe it has something to do with legal directory names between the two OS

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:27 pm
by actionHero
Thank you for the reply and suggestion.

I've made that change. The success and type of success on the Mac still =undefined. The Windows machine is working fine.

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:28 pm
by gabrielp
actionHero wrote:Thanks for your reply.

I've added that option and no such luck. When I do a s.log() and get the "type of" success, it returns as undefined. So then it can't enter the if/else statement.
Are you talking about the return from that function? If so, you need to pass it the Switch object.

Code: Select all

var my_url = "Folder" + getDirectorySeperator(s) + "filename.txt";

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:34 pm
by actionHero
Windows file path:
source C:/Users/Enfocus.KY-SW1/AppData/Roaming/Enfocus/Switch Server/temp/9/ScriptElement/90/79/KY_223777.sitx
arcjob C:\Switch\Arc1\KY_223\KY_223777.sitx

Type of Success= number

Mac file path:
source /Users/admin/Library/Application Support/Enfocus/Switch Server/temp/65/ScriptElement/35/82/KY_263066.zip
arcjob /Users/admin/Desktop/untitledfolder2/KY_263/KY_263066.zip

Type of Success= undefined

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:44 pm
by gabrielp
What version of Switch are you running this on?

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:46 pm
by actionHero
The Mac is Switch 12, upgrading in near fututre. Windows is running 13.

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:52 pm
by actionHero
I'm saying that when I try to get logs on "success" it's undefined on the Mac.

var success = s.copy( arcjob, theDestPath); //copy from archive to temp folder
s.log(2, "success " + success);// HERE=UNDEFINED
s.log(2, "type of " + success); //HERE =UNDEFINED

if(success == true){
s.log(2, "Pass");
job.sendToData(1, theDestPath ); //send file to next pass data connection
job.sendToNull(job.getPath()); // delete input job
} else {
job.log(3, "failed");
job.sendToData(3, job.getPath() ); //send original XML to failed field.
}
}

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 4:58 pm
by cstevens
Maybe a silly question, but is the outgoing connection(s) from the script set up as a stop light connection with a valid data connection? That undefined message could possibly be due to the sendToData not being a valid output location.

Based on the documentation this should throw an error message, but just checking.

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 5:23 pm
by actionHero
Thanks for the reply. Yes the traffic lights are setup to send data. I keep going back to the "s.copy" I don't think it's working. I can't pull a status from the variable.

Re: Fails on Mac but works on Windows (thats hard for me to say)

Posted: Thu May 25, 2017 5:50 pm
by gabrielp
So your s.copy is returning undefined, when it should be returning a boolean: http://www.enfocus.com/manuals/Develope ... class.html

I don't know why it would do that....