Sign in to follow this  
dle

Scp Upload?

Recommended Posts

Does the system.Shellexecute() can pass the parameter to the command line?

I have an execute program that require to be open in a command prompt call pscp.exe

 

system.ShellExecute("C:\Windows\System32\cmd.exe","open","C:\Test\pscp.exe","","show")

 

The command above will open the windows command line but won execute the pscp.exe.

 

 

Share this post


Link to post
Share on other sites

Technically shellExecute will run in a command prompt anyway.  But if you want to do it as you describe, I believe you need another flag, either /C if you want it to run and then the window close when its done, or /K if you don't want the window to close.  Go to a command prompt and type:

 

help cmd

 

and you can see all the flags.  Note that the flags would go in the same string as your "C:\Test\pscp.exe" and first, e.g.: "/C c:\Test\pscp.exe"

Share this post


Link to post
Share on other sites

Can you show me how to pass multiple parameters.

I'm trying to trigger and send a command to a tool called Putty.exe

 

System.Shellexecute("C:\Putty.exe","open","username@10.0.0.100","","show")

 

I could get it open and logging  using the username and ip address. I need to execute a few more commands with that Putty.exe command line.

 

I trid

System.Shellexecute("C:\Putty.exe","open",username@10.0.0.100: /ps -A,"","show")

 

but Putty wont open

Share this post


Link to post
Share on other sites

I just type it wrong when I post it.

I did try so many ways but still couldn't make it work.

 

System.Shellexecute("C:\Test\Putty.exe","open","username@10.0.0.100 ps -A","","show")

 

System.Shellexecute("C:\Test\Putty.exe","open","username@10.0.0.100 \\ps -A","","show")

 

System.Shellexecute("C:\Test\Putty.exe","open","username@10.0.0.100 :\\ps -A","","show")

.........

 

none of them working. Putty will confuse and see that the ip address will be 10.0.0.100 ps -A  and so on.

Share this post


Link to post
Share on other sites

Usually the flags (i.e. stuff with slashes or dashes) have to be in front of the thing without flags.  This is true with just about any command line program, and has nothing to do with DAQFactory.  So try putting -A first.  In fact, test it at the command prompt.  I think you will find that this doesn't work at the command prompt (outside DAQFactory) even:

 

c:\test\putty.exe username@10.0.0.100 /ps -A

 

Instead, you probably need:

 

c:\test\putty.exe /ps -A username@10.0.0.100

 

Though I don't see a ps flag in the putty docs.  

Share this post


Link to post
Share on other sites

I guess ps -A is a command within the server where putty connecting to.

 

I did: system.shellexecute("C:\Putty.exe","open","-ssh username@10.0.0.100","","open")

 

DF will open a putty command line session that showing putty successfully logging to username@10.0.0.100 using SSH protocol.

Now, on that command line session, I type "ps -A", it will list all of the processes are running within the server, then I type "slay Product", the Product's process will be refreshed.

 

Is it possible for DF to execute the command  "slay Product" after putty successfully logging to the server?

Share this post


Link to post
Share on other sites

No, DF can't execute commands once the application is open.  Most likely you'll have to look in the docs for Putty and see if there is a way to, for example, provide a batch file that it runs.  I know the Windows command line FTP tool has this, so I'm guessing putty does too.  You also might be able to use the windows pipe command, though likely you'll have to use a .bat batch file along with a call to cmd.exe to trigger it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this