Executing shell command from within a FTP session

I am trying to execute a ‘mkdir’ command from within a FTP session and am having no luck with any of the existing services. I have tried the fireCommand… service w/o luck.

Any suggestions?

Hi, Nigel. I am not sure if this is possible. Are you able to open a separate session using Java services and create the new path independent of the FTP session?

If not, you will continue to see the error message:

com.wm.app.b2b.server.ServiceException: 550 Could not open: No such file or directory

Are there any other work-arounds for you and your team?

Well, in a nutshell, my goal is to create a flow service that logs into an ftp server - then issues a ‘mkdir’ command and then puts files into that dir. The new directory name will be passed from the pipeline.

I just can’t seem to find a service that will issue the mkdir command…

Nigel,

While in the ftp session you should be able to issue the mkdir command such as ‘mkdir newdir’ upon a successful creation you should get a response code of 257 which you can check for to see if the creation went okay. HTH

Hi

I did not understand what you want, but try to use an application named psexec

Go to the site http://www.sysinternals.com/

This application run commands from a computer to others making a remote execute, like a ftp command but to run applications .
for example to create a directory or to run a program …
In unix system you can try to use rsh ( remote shell execute ) that make the same ( different way )

Thanks all for the feedback.

I’ll clarify a bit on my post.

I am writing a flow that will be passed data (i.e. directory name to create) and then will login to an ftp server. Once it is logged in, it is supposed to create the direcory that is passed. For this, I have the login piece working - now my problem is that I have not found anything within the IS 4.6 packages (i.e. wmSamples wmPublic, etc.) to issue a shell command. I wanted to pull in the service (WmSamples:sample:commandLineExec:fireCommandExec) but it wouldn’t work.

In reference to the sysinternals.com link - I’m not sure if I can use external code from within webMethods. I tried to write a service for this, but I’m afraid that my Java skills are not very good.

– thoughts?

Nigel,

If all you want to do is create a directory you don’t have to run a “shell command”, you have the ability within ftp to create a directory with a ftp command of ‘mkdir’ which so happens to be the same command in UNIX. So within Integrator you should be able to use pub.client:ftp with the command parameter set to ‘mkdir %variable%’.

I’m surprised that wM does supply a wm.client.fpt:mkdir service but it shouldn’t be too difficult to write it (famous last words). You’ll need to drop to Java to do it. Follow the parameter patterns of the of the other services to guide you.

Chris - Great idea on using pub.client:ftp - however, it will only allow you to use ls, get or put in the command option. There is a drop down box. (I was excited to try it and just found out that it won’t work)

As far as writing my own - I have tried to use the pub.client:ftp:* and those services do not allow you to view the code, else I would plagerize and get it to work. It seems this is a common task and I wonder if anyone has gotten around this…

Nigel,

Use pub.client:ftp, in the “Pipeline In” area create a variable with a default of ‘mkdir newdir’ then map it to the command varibable within the “Service In” This should allow you to enter more commands than what is available to you.

Didn’t work - great idea though.

I’ll see what else I can do - let me know if anyone has anything new to try (THIS should not be this difficult…!?)

Thanks!

Hi, all.

I am not facing this an a development issue, but now just a metter of curiosity. I have taken a few stabs at it and am coming up empty on the “trick the Built-In Service” approach.

I even went so far as to edit the input variable constraints of the WmPublic service pub.client:ftp. KIDS, DO NOT TRY THIS AT HOME! Changing the allowable pick list for “command” to include “mkdir”, “mkdir test” or “mkdir %var%” didn’t make a difference.

I am going to fall back on my earlier post and say to write this using Java is probably the best way. You should write a custom Java service to login, mkdir, and logout instead of piggy-backing the webMethods-instantiated session. Make sure the FTP Server accept multiple logins from the same account, if you Flow uses that sort of logic.

If somebody gets this to work, post it here for the group!

Didn’t work - great idea though.

I’ll see what else I can do - let me know if anyone has anything new to try (THIS should not be this difficult…!?)

Thanks!

Ok, this is ticking me off, everything I suggested didn’t work. Mental note, try it first before suggesting… I have tried this and it DOES work. Nigal use pub.client.ftp:quote, use the string of ‘mkd newdir’. Again I tried this and it does work. HTH

Nigal,

As a follow up you can while in ftp issue the command ‘quote help’ to see a list of commands you can use with quote, depending on the ftp server there is quite a few commands that can be used. HTH

Gosh darn it! The docs don’t match the services that are available. And someone had posted a request on Advantage to add the ‘quote’ service, so I didn’t even think to look for it in the package but there it is as big as you please! Thanks for the info Chris!

Wow - GREAT WORK and thank you. I did notice that ‘mkdir’ didn’t work for me (AIX Platform) - however, i used ‘mkd’ and it worked fine!

Thank you very very much!

Try the following quote command:
quote mkd folder

See the following web site:
http://www.w3.org/Protocols/rfc959/2_Overview.html