Use Unix shell script to open Windows command prompt (cmd)

Hello,
I work on Windows and I use Putty to access a remote UNIX server.
I am trying to build a shell script that will have as main task to open the
Windows command prompt (cmd) and run some Windows commands thereafter. The commands are actually file transfer commands that will download a file from the Unix server onto my local computer (Windows). I will specify all the commands within a text file and will pass that file
when calling the Windows command prompt so that they are then executed.

The challenge is how to call a Windows program (i.e. command prompt here) using Unix shell script!!!

The commands for the file transfer are working well, already tested. I'm using WinSCP. But the big thing as said is that I shall initiate that call from Unix (shell script).

Please help!
Any idea?

Thanks in advance.

Easyest might be to install something like sshd on that windows box, establish passwordless key authentication (exchange keys) and issue some simple ssh commando from the Unix box on the Windows box.

But then you could also just issue a scp from the Unix box towards the Windows box(?).

I tried to use the "scp" command but it failed. I think I have a problem specifying the Windows directory where the file needs to be downloaded. I have specified the directory directly as "D:\". Apparently it is searching for the address of my machine. But this would be a problem because I need a dynamic solution since files will be downloaded to many different machines.

ssh: D: no address associated with name
lost connection

Any idea on how to proceed?
Thanks

You can also share the windows folder, and use smbclient.
It should be avalible on any unix flavor with samba installed.

Check link down :
http://www.samba.org/samba/docs/using_samba/ch05.html
The part that says : Programming with smbclient

Thanks, but I have the restriction to do it by shell script.
The file transfer is only done when a user triggers a button on the desired file.
Once the initiation is made, the file should be transferred to his local machine (Windows).

Not exactly what you want but...I did this by installing an ftp server on my windows machine. After that you can easily put the files on to the windows machine from the unix server.

scp will only work, if there is an sshd (ssh-daemon) running on the target host. By default, windows doesn't bring a running ssh-daemon, as far as I know which means, you'd have to install and activate one.

A usual basic ssh invocation would be:

ssh bill@windowshost5

When sshd is up and running, ssh, scp and sftp can be used. They all use sshd.

If no keys are set up sshd would ask you for bill's password who must be an account that exists on the windows box of course.
If there would have been set up passwordless key authentication between them, you wouldn't even have to enter a password, as the name says.

Hello guys, I have been able to open the command prompt (actually COMMAND.COM) from a shell script.
I have used the following piece of code. It is quite amazing, but it does open command.com. To say frankly I don't know how it works. Perhaps you guys do know it.

echo ^[[17xC:\\COMMAND.COM

As you can see I had to copy COMMAND.COM in the C: directory because when calling it from its original location C:\WINDOWS\system32\COMMAND.COM I get an error message "Access denied". Do you guys have an idea why this is so?

The problem I'm having now is that I am not able to pass a file (+ an argument) as parameter. Error: Too many parameters.

I tried the following:

echo ^[[17xC:\\COMMAND.COM "C:\myfile\fileparam.dat" "param1"

HELP please!

why dont you use a batch file to get the file from unix serve ( ftp script )

As previously explained, I have to initiate the call from a Unix program. Only when a user activates a button should the file transfer occur.

user click button --> file download happens --> file downloaded to user desktop

1) where is the button available ? ( is it a web page ? -- hosted in unix machine ? )
2) Is file download should happen from unix machine ?
3) User is on the windows machine ?

1) Yes the application is hosted on a Unix machine. The interface is DOS-like. When user presses function key F11, file should be downloaded.
2) Yes the file should be downloaded from the Unix machine onto the user Windows machine, in a specific directory.
3) Yes the user has a Windows machine

Seriously? You're logged into a Unix server, and some echo command opens a command prompt on your windows machine. I'd like more information.

The only way to get a file from Unix to windows is to use one of the available protocols. You need to pick one of these, for example:
ftp
ssh/sftp/scp
samba/smb

Those are protocols that will transfer files between computers.

I can't help but think you are way off base on finding a solution.

Please pick a protocol and post your Unix program. Then we should be able to help.

Yes it does open the command prompt. As I said it is like magical. I don't know how it works, I have used some existing piece of code and it does the trick. But now I have to pass a file as parameter but it is not working?

Most probably the magic lies within the "^[[17x" part. But sincerely I don't know how it actually works.

Below is part of the piece of code, showing what I am trying to do.

Firstly I'm echoing some commands in a text file and then transfer that file on my local pc using kermit.
Secondly, I am supposed to call command.com with a file parameter so as to do some deletion in a specific directory. (not working presently since it is not accepting the file as a parameter)
Lastly, use winscp.com to download the file from Unix onto my Windows machine.

echo "
option batch on
option confirm off
open $LOGNAME:$PASNAME@$ADR_INT
option transfer binary
get $CFILE C:\\GLWIN\\myfiles\\$FILEPC
close
exit
" > myfile.txt

kermit -s myfile.txt

echo ^[[17xC:\\COMMAND.COM "C:\myfile\fileparam.dat" "param1"
echo ^[[7xD:\\winscp434\\winscp.com /console /script="C:\GLWIN\myfiles\myfile.txt"

It must be an escape sequence that instructs your terminal program to open the command prompt.

So it's your terminal emulator program that's opening it, not the UNIX server. Switch to a different terminal emulator and it'll likely not work.

This could also be easily abused by anyone who wanted to run anything else on your system.