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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Use Unix shell script to open Windows command prompt (cmd)
# 1  
Old 08-10-2011
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.
# 2  
Old 08-10-2011
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(?).
# 3  
Old 08-10-2011
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.

PHP Code:
sshDno address associated with name
lost connection 
Any idea on how to proceed?
Thanks
# 4  
Old 08-10-2011
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
# 5  
Old 08-10-2011
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).
# 6  
Old 08-10-2011
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.
# 7  
Old 08-10-2011
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:
Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script not working but command works in command prompt

Hi everyone I have a problem with my script If I try directly this command /usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz It works But if I simply add this command in a script and... (8 Replies)
Discussion started by: picemma
8 Replies

2. UNIX Desktop Questions & Answers

Can Unix access Windows' File through Command Prompt in Unix

Hi all, I wish to know whether Unix can access window's file in Unix's terminal? Apart from that, how to copy files or share files between Window and Unix? I get to know of secure copy, however, my company's Unix does not support the feature of secure copy? Any other method for me to share/... (5 Replies)
Discussion started by: jessy83
5 Replies

3. Shell Programming and Scripting

how to change unix cmd display prompt?

I am new to to unix and I want to make my own basic shell. What is the code I can use to change the unix cmd console display? For example my unix display prompt says MyCompterName~, I want it to say WhatEverMan~ (3 Replies)
Discussion started by: megaearth77
3 Replies

4. Windows & DOS: Issues & Discussions

script to open new cmd prompt for devices on visio

Hello, Can any one please help: I have a lab design on Visio, with routers and switches. What I am planning to do is: when I double click a device icon - it should open a new cmd prompt window and automatically performs the telnet session and log's me into the device. Appreciate your... (0 Replies)
Discussion started by: sureshcisco
0 Replies

5. Shell Programming and Scripting

MKS KORN SHELL WONT EXECUTE from windows command prompt

Can anybody help me with this small script , the script works fine and launches the IE from c:\documents and settings \test\my documents>ksh prompt $RunURL1.sh this scitpt works and launches the ie from ksh , but when i schedule it to run the script then i get the error box saying command:1... (2 Replies)
Discussion started by: venu
2 Replies

6. Homework & Coursework Questions

Unix Shell Script to prompt customer for name etc

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following:... (4 Replies)
Discussion started by: SQLScript
4 Replies

7. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

8. Shell Programming and Scripting

open terminal to run cmd using shell script

i want the shell script to open the terminal and in that terminal i want to run a command specified in the script... how can it be done... (2 Replies)
Discussion started by: chandrabhushan
2 Replies

9. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

10. Shell Programming and Scripting

Interaction shell cmd prompt

hi , how do i interact with the shell prompt. i need no. of args to be dynamic e.g $> type the no of args: <input from keyboard> Enter the 1 st arg : <input from keyboard> Enter the 2nd arg : <input from keyboard> ......... ......... let me know how to do it ... (1 Reply)
Discussion started by: adityamahi
1 Replies
Login or Register to Ask a Question