'sqlcmd' is not recognized as an internal or external comman

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
3 posts Page 1 of 1

mpan20

Posts: 5
Joined: Mon Sep 23, 2013 12:35 pm

Post by mpan20 » Fri Jan 22, 2016 4:38 pm
Today I installed the Microsoft Command Line Utilities 11 for SQL Server on our GoAnywhere server. I need to be able to run sqlcmd and bcp commands in batch files to grab data from SQL Server databases. The batch file is written and if I execute it manually on the server, everything works as it should. The batch file queries the database and generates a CSV file with the data. The issue is when I run that same batch file inside a project it fails. The log shows that the sqlcmd and bcp commands are not recognized as commands even though they run fine outside of the GoAnywhere project. The section of the log with the error is below. Any thoughts?
Code: Select all
D:\Archive\Lawson-HCSNetLearning>sqlcmd -E -S SWDATADB -i D:\Archive\Lawson-HCSNetLearning\Code\CreateNetLearningTables.sql 
1/22/16 4:28:26 PM            INFO      'sqlcmd' is not recognized as an internal or external command,
1/22/16 4:28:26 PM            INFO      operable program or batch file.
1/22/16 4:28:26 PM            INFO      
1/22/16 4:28:26 PM            INFO      D:\Archive\Lawson-HCSNetLearning>bcp "SELECT '!Last Name','First Name','EmployeeID','Address 1','Address 2','City','State','Zip','Phone Number','People Group','Organization Title','Organization Abbreviation','Job Title','Department','Dept Number','E-mail','Hire Date','Middle Name','Supervisor ID','Badge Number' UNION SELECT LName,FName,EmpID,Address1,Address2,City,State,Zip,Phone,PeopleGroup,OrgTitle,OrgAbbv,Job,DeptName,DeptNum,Email,HireDate,MName,SupervisorNum,BadgeNum FROM tempdb.dbo.NetLearningPeopleTable" queryout D:\Archive\Lawson-HCSNetLearning\SWGHC.csv -S SWDATADB -T -c -t"|" 
1/22/16 4:28:26 PM            INFO      'bcp' is not recognized as an internal or external command,
1/22/16 4:28:26 PM            INFO      operable program or batch file.
1/22/16 4:28:26 PM            INFO      
1/22/16 4:28:26 PM            INFO      D:\Archive\Lawson-HCSNetLearning>sqlcmd -E -S SWDATADB -i D:\Archive\Lawson-HCSNetLearning\Code\DropNetLearningTables.sql 
1/22/16 4:28:26 PM            INFO      'sqlcmd' is not recognized as an internal or external command,
1/22/16 4:28:26 PM            INFO      operable program or batch file.
1/22/16 4:28:27 PM            INFO      The native command 'D:\Archive\Lawson-HCSNetLearning\Code\CombineFiles.bat' finished with a return code of '1'  
1/22/16 4:28:27 PM            ERROR     [9003 - exec] The executable encountered an error with a return code of '1'.  To ignore this error, set the attribute 'errorIfExecutableFails' to false.
1/22/16 4:28:27 PM            INFO      Finished project 'NEW Lawson to NetLearning Employee Interface'
1/22/16 4:28:27 PM            ERROR     [9003 - exec] The executable encountered an error with a return code of '1'.  To ignore this error, set the attribute 'errorIfExecutableFails' to false.
                                        com.linoma.ga.projects.runtime.JobFailedException: [9003 - exec] The executable encountered an error with a return code of '1'.  To ignore this error, set the attribute 'errorIfExecutableFails' to false.
                                        	at com.linoma.ga.projects.runtime.Job.run(Unknown Source)
                                        	at com.linoma.ga.projects.runtime.Runtime.executeProject(Unknown Source)
                                        	at com.linoma.ga.projects.runtime.Runtime.executeProject(Unknown Source)
                                        	at com.linoma.ga.projects.runtime.Runtime.executeProject(Unknown Source)
                                        	at com.linoma.ga.ui.admin.projects.explorer.ProjectListForm.runProject(Unknown Source)
                                        	at sun.reflect.GeneratedMethodAccessor13246.invoke(Unknown Source)
                                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                        	at java.lang.reflect.Method.invoke(Method.java:597)
                                        	at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
                                        	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
                                        	at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
                                        	at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
                                        	at org.primefaces.application.DialogActionListener.processAction(DialogActionListener.java:45)
                                        	at javax.faces.component.UICommand.broadcast(UICommand.java:120)
                                        	at javax.faces.component.UIData.broadcast(UIData.java:1618)
                                        	at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1172)
                                        	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:365)
                                        	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1656)
                                        	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:862)
                                        	at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:42)
                                        	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
                                        	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
                                        	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.ga.core.upload.FileUploadFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.dpa.security.SecurityFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.ga.ui.core.filter.IFrameEmbeddingFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.ga.ui.core.filter.NoCacheFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.ga.ui.core.filter.IECompatibilityModeFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at com.linoma.dpa.j2ee.AdminRedirectFilter.doFilter(Unknown Source)
                                        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                                        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                                        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
                                        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
                                        	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
                                        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
                                        	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
                                        	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
                                        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
                                        	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
                                        	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
                                        	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
                                        	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                                        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                                        	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                                        	at java.lang.Thread.run(Thread.java:662)
                                        Caused by: com.linoma.dpa.ExecutionException: [9003 - exec] The executable encountered an error with a return code of '1'.  To ignore this error, set the attribute 'errorIfExecutableFails' to false.
                                        	at com.linoma.ga.projects.tasks.exec.Executor.handleErrorIfExecutableFails(Unknown Source)
                                        	at com.linoma.ga.projects.tasks.exec.Executor.execute(Unknown Source)
                                        	at com.linoma.ga.projects.tasks.exec.ExecTask.execute(Unknown Source)
                                        	at com.linoma.ga.projects.Module.execute(Unknown Source)
                                        	at com.linoma.ga.projects.Project.execute(Unknown Source)
                                        	at com.linoma.ga.projects.runtime.Job.executeProject(Unknown Source)
                                        	... 57 more
1/22/16 4:28:27 PM            INFO      End Date and Time: 1/22/16 4:28:27 PM

mpan20

Posts: 5
Joined: Mon Sep 23, 2013 12:35 pm

Post by mpan20 » Mon Jan 25, 2016 2:41 pm
As an update, this is working now once I included the full path to the executable. Odd that the batch file works from a command prompt on the server without the full path when running manually, but not when called from the GoAnywhere job. At least it is resolved and the job works perfectly now.

Full path to the executables:

C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\sqlcmd.exe
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\bcp.exe

Support_Tim

Posts: 30
Joined: Mon Dec 01, 2014 10:35 am

Post by Support_Tim » Mon Jan 25, 2016 3:39 pm
Hi MPan20,

That was going to be the recommendation, so I am glad it worked out.

"It appears that GoAnywhere is not finding the command. Make sure that the SQL command is where GA can find it or you are using a qualified path name with your command."
3 posts Page 1 of 1