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

Post Reply
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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.
}
}
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

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

Post 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;
};
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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.
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

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

Post 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
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

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

Post 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";
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

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

Post by gabrielp »

What version of Switch are you running this on?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post by actionHero »

The Mac is Switch 12, upgrading in near fututre. Windows is running 13.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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.
}
}
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

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

Post 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.
actionHero
Member
Posts: 37
Joined: Thu May 18, 2017 12:06 am

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

Post 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.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

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

Post 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....
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply