?
Solved

RUNRMTCMD

Posted on 2006-07-19
33
Medium Priority
?
5,748 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 10
  • 4
  • +2
33 Comments
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 17139102
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
ID: 17139134
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
ID: 17139226
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 17140982
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
ID: 17141012
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
ID: 17141436
Yes you'r right
and if you loged in on the IFS then no extra login is required.
0
 

Author Comment

by:boydosborne
ID: 17141481
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
ID: 17141742
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 33

Expert Comment

by:shalomc
ID: 17142140
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
ID: 17145907
Warning: This will create a gaping security hole on your windows machine.

What another one!!!!!!!
0
 

Author Comment

by:boydosborne
ID: 17146315
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 33

Expert Comment

by:shalomc
ID: 17146694
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
ID: 17146755
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 33

Expert Comment

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

ShalomC
0
 

Author Comment

by:boydosborne
ID: 17147467
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
 
LVL 33

Expert Comment

by:shalomc
ID: 17147880
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
ID: 17148059
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
ID: 17153997
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 33

Expert Comment

by:shalomc
ID: 17155907
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
ID: 17155982
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 33

Expert Comment

by:shalomc
ID: 17156028
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
ID: 17156063
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
ID: 17156144
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 33

Expert Comment

by:shalomc
ID: 17156399
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
ID: 17156433
The err.txt is never created.  The joblog on the as400 says access denied.
0
 
LVL 33

Expert Comment

by:shalomc
ID: 17156618
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
ID: 17156733
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 33

Expert Comment

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

0
 

Author Comment

by:boydosborne
ID: 17156836
Win2000 there are not any restrictive group policies on the server
0
 
LVL 33

Accepted Solution

by:
shalomc earned 500 total points
ID: 17156923
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
ID: 17157008
The scheduled job worked fine.  The batch file ran and it copied the required file.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 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