SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Long command strings over RARunandWait
Goto page 1, 2  Next
 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Long command strings over RARunandWait
Author Message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Long command strings over RARunandWait Reply with quote
Hi
When I try to run a long command string ie
c:\fds\applications\sftpc -keypairFile=c:\\keys\\XXXXXXXX root@XX.XX.XX.XX -cmd="put c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt"

I get an error; Line 59: Remote Access Eroor: java.io.IOException
Error:Access is denied.

When I shove the same command in a batch file on the agent box and run that over the rarunandwait it works.

Is there a character limit?
Tue Mar 11, 2008 8:35 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
This command is about 180 characters long, if in front of that you add path/name to the utilities like RunAs that the agent might be using to execute each requested command using a particular user account, you might be approaching 255 characters limit for a command parameter length for your operation system. I suggest to check agent's log files and run it with the log/tracing options enabled to see what you get in the trace log file and whether the requested command appears truncated.

By the way, where do you get "Error:Access is denied" on the agent side or the scheduler side? What kind of agent are you running?
Tue Mar 11, 2008 9:14 pm View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
I get access is denied from the debugger on the master scheduler

The agent is the Java remote agent for Windows.

This is what I get in the log file, how does one enable tracing for the java remote agent?

12 Mar 2008 13:34:11 INFO [run]: end
12 Mar 2008 13:34:11 INFO [run]: start
12 Mar 2008 13:34:11 INFO [authenticate]: start. user = XXXXX
12 Mar 2008 13:34:11 INFO [authenticate]: end. result = User authenticated.

12 Mar 2008 13:34:11 INFO [main]: Worker start
12 Mar 2008 13:34:13 ERROR [error]: java.io.IOException:
Error: Access is denied.
Tue Mar 11, 2008 9:20 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
In this type of agent you can enable additional logging by changing logging level from INFO to DEBUG in the logging.properties file. This file can be found inside ra_server.jar (Note that .JAR files are regular .ZIP files, just a different extension).

My guess, the problem is not in the command length. The agent could be having difficulties understanding the command syntax, perhaps some extra double quotes are needed; or when running from an agent the referenced sftp utility could be unable to locate some files looking for them in a wrong place because the command working directory is not what you are expecting. I noticed that you refer to relative file names, try using full names instead.
Tue Mar 11, 2008 9:52 pm View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
Here is the debug log, i've x'd the ip's and auth details. I will have a play with quotes as well


12 Mar 2008 15:06:53 INFO [execute]: start
12 Mar 2008 15:07:01 INFO [run]: start
12 Mar 2008 15:07:02 INFO [authenticate]: start. user = kbstfdsext01v\payments01
12 Mar 2008 15:07:02 INFO [authenticate]: end. result = User authenticated.

12 Mar 2008 15:07:02 INFO [main]: Worker start
12 Mar 2008 15:07:02 DEBUG [main]: Wait next data packet...
12 Mar 2008 15:07:06 DEBUG [main]: Header received: magic: 0x52417261 command: 20 reply: 60 arg0: 0x4 arg1: 0x11455497 arg2: 0xef0060 length: 184
12 Mar 2008 15:07:06 DEBUG [execRun]: start
12 Mar 2008 15:07:06 DEBUG [execRun]: Command: c:\fds\applications\sftpc -keypairFile=c:\\keys\\XXXXXXXXXXX XXXX@XXXXXXXXXXX -cmd="put c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt"
12 Mar 2008 15:07:06 DEBUG [execRun]: Startup dir: C:\ra_server
12 Mar 2008 15:07:06 ERROR [error]: java.io.IOException:
Error: Access is denied.
Tue Mar 11, 2008 10:09 pm View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
I'm getting some crashes to desktop when debugging as well. Not sure if related as it's not predictable.
Tue Mar 11, 2008 10:13 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
This line might be important: DEBUG [execRun]: Startup dir: C:\ra_server
Again, you are using relative file names and I doubt you have C:\ra_server\download subfolder


Last edited by SysOp on Tue Mar 11, 2008 10:40 pm; edited 1 time in total
Tue Mar 11, 2008 10:14 pm View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
No I don't have a download folder but the command runs an ssh client to run the quoted piece of the string on another server again and it certainly won't be trying to access the download folder locally. The local part of the string is an absolute file name.

The problem, however....and I do feel quite stupid now.....is that the sftp application was one directory down from where the script thought it was.

Just a very misleading error message.

Thanks for your help :-)
Tue Mar 11, 2008 10:27 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
I've seen this kind of generic error before "java.io.IOException. Error:Access is denied." wnenever it cannot open a folder or file, that's why I was suspecting it could be a path issue

Please don't forget to undo the logging properties change. You probably don't want other people to find user and password in plain text in the log file.
Tue Mar 11, 2008 10:44 pm View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
So the error is fixed but there's still something I don't understand.

When I supply my long commandline I've already posted to RARunandWait, the application it launches on the target box fails with a bad syntax error.

When I run that commandline exactly the same on the server myself as opposed to via the agent it works fine
When I have 24x7 write the command to a batch file on the server, and run the batch file, it works fine

Now this is a workaround but it's quite inelegant. The RA connection must be stripping something out or putting carriage returns in, although in the debug log for the agent it shows as I would hope

12 Mar 2008 16:08:04 DEBUG [execRun]: Command: c:\fds\applications\sftpc\sftpc.exe -keypairFile=c:\\keys\\XXxxxxxx xxxx@xxxxxxxxxxx -cmd="put c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt"

This is correct to the letter but the app still fails. Mystery!!
Tue Mar 11, 2008 11:42 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
Well the command you see in the DEBUG line is not the full story. Let me first describe how it works, so that the rest makes sense.

The agent is a server like application consisting of a network listener and server parts and so called "runners." The listener and server parts are multi-platform parts and are the same for all supported systems. The runners are host system specific because they need to know how to tell the system which account to use for the process and how to authenticate against that user account. So the complete command line invoked by the server is the "runner" process invocation command following by the command line that you pass from the remote scheduler.

Now about the cause of the issue. Remember that in Windows double quotes are used as delimiters for command line parameters.

If you look at the complete command as [runer] [runner parameters] [your command line here] you will se that from the runner's point of view it gets your command as below - program name following by 4 parameters for that program, not 3
1. c:\fds\applications\sftpc\sftpc.exe
2. -keypairFile=c:\\keys\\XXxxxxxx
3. xxxx@xxxxxxxxxxx
4. -cmd=
5. put c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt

Indeed, what you need is 4 and 5 together, but double quotes break them apart. In theory you can plain with that and find the right syntax using extra quotes, maybe extra backslahes and this could become really complicated. I suggest that instead of that path, you choose an easy solution. All you really have to do is to save harmless command to a batch file on the agent side and then execute it with 2 authentication parameters - for the user and password, for example,


Code:
RAFileSave "do_it.bat", "c:\\fds\\applications\\sftpc\\sftpc.exe -keypairFile=c:\\keys\\%1 %2 -cmd=\"put c:\\fds\\working\\sftptest\\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt\""
RaRun "do_it XXxxxxxx xxxx@xxxxxxxxxxx", process_id

Wed Mar 12, 2008 12:12 am View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
The problem with that workaround is that I don't think you can collect the return code from the program without a 'exit %errorlevel%' in the batch file so I put that in with RAfilewrite commands to get the carriage return and the second command.

The problem then is on the next run when I can't seem to delete the file over the ra link, and if I use filesave I get gibberish in the file.
Wed Mar 12, 2008 12:30 am View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
The other odd thing is in the ssh client log it actually splits the command slightly later than you thought
instead of
4. -cmd=
5. put c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt
it's actually
4. -cmd="put
5. c:\fds\working\sftptest\210.txt download/210.txt.tmp; mv download/210.txt.tmp download/210.txt"

so it's not splitting at the quotes it's at the space.
Wed Mar 12, 2008 12:39 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
You can add exit %ERRORLEVEL% to the end of batch file to make it return an error code; and RAFileSave should always overwrite the batch file on every run, not sure what you mean by "gibberish."

To capture the exit code, don't use RARun to run the command because it just launches the process and lets it go. Instead, use RARunAndWait to make the job wait for the process completion. The exit code can be then obtained using RAProcessExitCode call. If necessary you can make the job fail using RaiseError if you don't like the received exit code.
Wed Mar 12, 2008 12:45 am View user's profile Send private message
LeeD



Joined: 17 May 2007
Posts: 311
Country: New Zealand

Post Reply with quote
By gibberish I mean this :-)

挀尺摦屳灡汰捩瑡潩獮獜瑦捰獜瑦捰攮數ⴠ敫灹楡䙲汩㵥㩣屜敫獹屜摦畳楮⹸牰⁶潲瑯ㅀ⸰㐲㠮⸳ㄲⴠ浣㵤異⁴㩣晜獤睜牯楫杮獜瑦瑰獥屴ㄲ⸰硴⁴潤湷潬摡㈯〱琮瑸琮灭※癭搠睯汮慯⽤ㄲ⸰硴⹴浴⁰潤湷潬摡㈯〱琮瑸攊楸⁴䔥剒剏䕌䕖╌

this is the code that produces that
RAFileSave( "c:\\fds\\scripts\\sftpop.bat", "" )
RAFileOpen( "c:\\fds\\scripts\\sftpop.bat", "LineMode", "Write", True, Filehandle )
RAFileWrite( filehandle, commandstring )
RAFileWrite( filehandle, "\n" )
RAFileWrite( filehandle, "exit %ERRORLEVEL%" )
RAFileClose( filehandle )

RARunAndWait( "c:\\fds\\scripts\\sftpop.bat", 0, pid, comline )

The heiroglyphs is what I see in the batch file after this code has run.
Wed Mar 12, 2008 6:51 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.