Solved

RUNRMTCMD

Posted on 2006-07-19
33
5,461 Views
Last Modified: 2012-06-21
Hello,

I am trying to run the following batch file from a CL program on the AS400.  The batch file copied a text file to the iSeries IFS and then I import it into a database table.  The program appears to run, but the file is never showing up on the IFS.  I have checked my job lock and it shows that the program completed but with no results.  Is there anything wrong with the way I have the RUNRMTCMD written?

                                                         
  RUNRMTCMD  CMD('c:\Program +                            
               Files\AscentSS\AscentSV\DATEDSPLY.BAT') +  
               RMTLOCNAME('10.202.120.113' *IP) +        
               RMTUSER(*NONE)                            

My user ID and password are the same between the iSeries and the server.
0
Comment
Question by:boydosborne
  • 14
  • 10
  • 4
  • +2
33 Comments
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Im not sure what you trying to do,

Is the RUNRMTCMD not oly between 2 AS/400's ?

did you already tried the STRPCCMD
before it will work, you have to start the command STRPCO

Regards,
murph
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
About the RUNRMTCMD; do you have enough authorization on the remote server?
doesn't the remote server require an user id and password?
0
 

Author Comment

by:boydosborne
Comment Utility
I am wanting to call a PC batch file.  The system does require a user ID and Password.  I was reading the documentation on the User ID option within RUNRMTCMD and I thought that is you do not supply a user ID it will use your AS400 user ID and password?  

I am trying to call a batch file on a PC server from a CL program on our iSeries.  Is this possible with the RUNRMTCMD?

Thansk,
Chris
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
try to store the .bat file on the IFS and use STRPCCMD,
with as parameter \\123.123.123.123\path\mybat.bat

That's the way I start some transfer jobs
0
 

Author Comment

by:boydosborne
Comment Utility
I am guessing that that the IP address in the STRPCCMD would be the IP address of the iSeries which is also the same iSeries I am running the CL program?

Thanks,
Chris
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
Comment Utility
Yes you'r right
and if you loged in on the IFS then no extra login is required.
0
 

Author Comment

by:boydosborne
Comment Utility
This did not execute.  Of course the batch file is trying to copy a PC text file that is in a directory on the server.  I am not sure if this would impact the results or not.  Here is what I have so far.  I have a CL program that has STRPCCMD for the batch file that I copied onto the IFS folder ( Chris).  The STRPCCMD is listed below.  The original Batch file is still located on the server where I am trying to execute the .bat file.  Does this sound like it shoudl work?

STRPCCMD   PCCMD('\\10.202.120.216\CHRIS\DATEDSPLY.BAT')
0
 
LVL 27

Expert Comment

by:tliotta
Comment Utility
Chris:

1) Is there an rexec server on the PC? I.e., what is on the PC that receives the remote command and executes it?

2) What are the rexec service attributes? I.e., assuming you have an rexec server on the PC, how is it defined to run? Does it run under the user account? Does it run as a different account? Does it discard commands that aren't authorized?

If you see no messages in the joblog on the AS/400 when RUNRMTCMD runs, then you need to review the system logs on the PC to find out what's happening. There might be entries in the Event Viewer for the security log, the sytem log or the application log. Or messages could be logged anywhere; you'll need to look at the documentation for your PC rexec server to know what to look for.

Most commonly, people use the iSeries Access Run Remote Command service. Most often, it needs to be tweaked to the proper configuration for the environment before it works. (Not unlike every other rexec server I've seen.)

Tom
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
Chris,
STRPCCMD can only be used in an online session and it will work only on the PC having this session.
RURMTCMD is used in a session independent way and can run in batch, but as implied by tom's answer, you need a rexec service on the PC.
If you want the iSeries Access Run Remote Command service without requiring user and password, then you must modify its startup definition by adding the /nosecok switch to the service program.

Warning: This will create a gaping security hole on your windows machine.

Log in as administrator to the windows machine and run from command line

sc config Cwbrxd  start= auto binpath= "C:\WINDOWS\CWBRXD.EXE /nosecok"

ShalomC
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Warning: This will create a gaping security hole on your windows machine.

What another one!!!!!!!
0
 

Author Comment

by:boydosborne
Comment Utility
Client access is installed on the Server.  I activate the iSeries Access for Windows Remote Command service.  I was thinking that this would be used for the remote command from the iSeries server.  I have found the REXEC.exe file in the WINNT/System32 directory.  What is the command to setup this exe as a service.  I tried the "service start rexec" command, but service does not appear to be a command.  I also tried REGSVR32 "C:\WINNT\System32\rexec.exe", but this did not work either.  I cannot open the secutiry hole.  This is not even an option, I will need to this configuration to be secured.  Any assistance or advice is greatly appreciated and thank you for all of your feedback up to this point.

Chris
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
try

net start "iSeries Access for Windows Remote Command"

or

sc start Cwbrxd

or look in the services console for "iSeries Access for Windows Remote Command"

ShalomC
0
 

Author Comment

by:boydosborne
Comment Utility
I have the iSeries Access for Windows Remote Command started.  This service was already configured for me, I guess it was setup when I installed Client Access Express.  Is there an application log for this service that i can check and see what activity if any?

Thanks, Chris
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
No application logs that I know of. Not even in the windows event log.

ShalomC
0
 

Author Comment

by:boydosborne
Comment Utility
Is there any file or setup any where that I can tweak the service to see if I can make it work.  I think the code is fine, I just do not think I am taking to the server.  Does any ports have to open on the server or does the Windows Remote Command service listen on a certain port.  Is there a simple code set that I could put in a CL to test the communication with the server?  

Maybe STRPCCMD(cmd)?  If the command works then a DOS command shell should open correct?

Thanks,
Chris
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 32

Expert Comment

by:shalomc
Comment Utility
execute
RUNRMTCMD CMD('dir > c:\rmt2.txt')    RMTLOCNAME('10.10.10.10' *IP) RMTUSER(chris) RMTPWD(password)

and look for the c:\rmt2.txt file on the server. If it is there and it contains the dir results, then you're ok.

ShalomC
0
 

Author Comment

by:boydosborne
Comment Utility
That actually worked, with the same layout of the above source.  If i wanted to call a batch file, I would just simply have:  
RUNRMTCMD CMD('C:\CHRIS\CHRIS.BAT') RMTLOCNAME('10.10.10.10' *IP) rmtuser(chris) rmtpwd(password)
0
 

Author Comment

by:boydosborne
Comment Utility
Just for testing purposes I tried to copy a file.  Below is the statement that I am using.  The copy is not working.   It is very frustrating that the dir > c:\test.txt statement worked, but changing it to copy c:\test.txt t:\ does not work.  Any suggestions.  

With the RUNRMTCMD, do I have access to all dos commands?

Thanks
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
I can't check it now, but as far as I remember I never had such problems.
yes, you have access to all dos commands that the user you use has access to.
copy should be no problem.

try this

copy c:\test.txt t:\ > c:\err.txt

this will save all messages form the copy command to err.txt

0
 
LVL 27

Expert Comment

by:tliotta
Comment Utility
Chris:

Just to be certain, if you logon to that PC as chris/password and run [copy c:\test.txt t:\], do you need to do _anything_ else other than type the command on a command line and press [Enter] to make it work?

Tom
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
Chris,
test your commands by using the native pc rexec client.
type rexec on a command line to figure it out..

0
 

Author Comment

by:boydosborne
Comment Utility
I can execute any command once I log onto the server.  I am actually an administrator on the server.  I did change my logging for this command and I set user = %userid% within the batch file, just to see what would be returned to the iSeries joblog.  I noticed that user was set to blank.  Is this normal?  Should the user ID from the RUNRMTCMD be in the %userid% field?

Thanks
0
 

Author Comment

by:boydosborne
Comment Utility
reexec said that access is denied when I use my network user ID and password.  I can type this command within dos and it works fine.  Where would my authority to use commands be controlled?  May I change any settings?

Thanks,
Chris
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
Chris,
we have an anchor - you succeeded to run a dir command.

try

RUNRMTCMD CMD('copy c:\test.txt t:\ > c:\err.txt')    RMTLOCNAME('10.10.10.10' *IP) RMTUSER(chris) RMTPWD(password)


what does the err.txt file show?

ShalomC
0
 

Author Comment

by:boydosborne
Comment Utility
The err.txt is never created.  The joblog on the as400 says access denied.
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
can you still run the remote dir command?

if you can, then try this command

cmd /C "copy c:\test.txt t:\ "

0
 

Author Comment

by:boydosborne
Comment Utility
Here are the results sent back from the command and also included is the command that you gave for verification.  It is like the server is refusing my access. But I don't understand or know what the configuration is set to not allow this operation to work.


CMD('cmd /C "copy c:\test.txt t:\ "') +

 Access is denied.        
         0 file(s) copied.
                           
                           
                           
                           
                           
                           
0
 
LVL 32

Expert Comment

by:shalomc
Comment Utility
What server is it? win2000? win2003? do you have any restrictive group policy on the server?

0
 

Author Comment

by:boydosborne
Comment Utility
Win2000 there are not any restrictive group policies on the server
0
 
LVL 32

Accepted Solution

by:
shalomc earned 125 total points
Comment Utility
how is the T: drive mapped? if it is bound to your interactive session, like Novell volumes, then it is not available to a non-interactive session started by rexec.

schedule the same failing command in the windows task scheduler, disable the "run only if logged on" parameter, and set "run as" to your user. see if it works. if it doesn't work, then the problem definitely has to do with differences between logged in sessions and batch sessions.

 
0
 

Author Comment

by:boydosborne
Comment Utility
The scheduled job worked fine.  The batch file ran and it copied the required file.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now