Fails on Mac but works on Windows (thats hard for me to say)
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Fails on Mac but works on Windows (thats hard for me to say)
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.
}
}
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)
Perhaps it's because the directory separators are different between windows and mac?
Try this function:
Try this function:
Code: Select all
// Determine directory seperator
var getDirectorySeperator = function( s : Switch ){
var directorySeperator;
if(s.isMac()){
directorySeperator = '/';
} else {
directorySeperator = '\\'
}
return directorySeperator;
};
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
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.
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)
This line doesn't seem right to me:
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:
not sure why this is working on Windows, maybe it has something to do with legal directory names between the two OS
Code: Select all
var theDestPath = job.createPathWithName(job.getNameProper(), false) + "." + ext; // create a temp spot to copy
I think what you want is:
Code: Select all
var theDestPath = job.createPathWithName(job.getNameProper() + "." + ext, false); // create a temp spot to copy
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
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.
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)
Are you talking about the return from that function? If so, you need to pass it the Switch object.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.
Code: Select all
var my_url = "Folder" + getDirectorySeperator(s) + "filename.txt";
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
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
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)
What version of Switch are you running this on?
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
The Mac is Switch 12, upgrading in near fututre. Windows is running 13.
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
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.
}
}
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)
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.
Based on the documentation this should throw an error message, but just checking.
-
- Newbie
- Posts: 15
- Joined: Thu May 18, 2017 12:06 am
Re: Fails on Mac but works on Windows (thats hard for me to say)
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)
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....
I don't know why it would do that....
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix