Execute a UNIX script from DOS prompt.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute a UNIX script from DOS prompt.
# 8  
Old 11-28-2006
HI All,

I am also keen to know how to execute UNIX command thru batch script??
Or is it that batch script cannot perform such function at all ?

Can some experts give some advice pls ?
Thanks
# 9  
Old 11-28-2006
Some of the ways to execute Unix scripts via a batch environment (windows) is to use protocols such as Telnet, or SSH, and also a good scripting language that supports these protocols
eg
Using Perl Telnet module

Perl SSH Interface

Python SSH

Python Telnet module

In pure windows batch, not that i know of.

Last edited by ghostdog74; 11-28-2006 at 10:53 PM..
# 10  
Old 12-12-2006
Hi Ghost Dog,

Thanks for the info. But i don;t seem to comprehend these methods and the interface.

Take an example of a csh script named "testing"

#!/bin/csh
echo " hello " >> hello.csv


How would i launch this from my windows using Perl telnet modules? Can you give me some guidance ?
# 11  
Old 12-12-2006
Quote:
Originally Posted by Raynon
Hi Ghost Dog,

Thanks for the info. But i don;t seem to comprehend these methods and the interface.

Take an example of a csh script named "testing"

#!/bin/csh
echo " hello " >> hello.csv


How would i launch this from my windows using Perl telnet modules? Can you give me some guidance ?

hi
everytime you telnet to your machine, there is a login and password prompt
eg
login:
Password:

then when you logged in, the user prompt according to how its shell profile is configured. For my machine and my user that i use for testing, the prompt is

sun4#

So you can try this (Perl telnet module)

Code:
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
                             Errmode=>'die');
 $telnet->open('your_telnet_server');
 $telnet->waitfor('/login:/'); # change this according to your telnet prompt
 $telnet->print('youraccount');
$telnet->waitfor('/Password:/'); #change this according to your telnet password prompt
$telnet->print('youraccountpassword');
 $telnet->waitfor('/sun4\#/'); #change this to the prompt of the user you are testing
print $telnet->cmd('./testing.sh');  
print $telnet->cmd('echo " hello " >> hello.csv');
$telnet->close();

# 12  
Old 12-12-2006
Hi Ghostdog,

For the prompt, how do i find out how the shell profile is being configured. The OS that i will being telnetting is Solaris and i will be activating csh script inside one of the directory.

And, how do i execute this perl script from my windows ?
# 13  
Old 12-12-2006
Quote:
Originally Posted by Raynon
Hi Ghostdog,

For the prompt, how do i find out how the shell profile is being configured. The OS that i will being telnetting is Solaris and i will be activating csh script inside one of the directory.

And, how do i execute this perl script from my windows ?
you can manually telnet to the solaris server using the user account.
then after its logged in, it will have a prompt. Just have to take note of it and assign it in your perl script. In shell, its commonly called the PS1 variable
check here for details. In Solaris, the user profile is usuall .profile in the home dir. you can set the PS1 variable in its profile.

In windows, with perl installed, just type
Code:
c:\somedir> perl yourscript.pl

assuming your perl script "yourscript.pl" is in the c:\>somedir directory
# 14  
Old 12-12-2006
Hi Ghostdog,

The last line after i keyed in my password is below. So do i assign "You have new mail" or "$" ?

You have new mail.
$


Can you recommend me a website to download and install perl ?


Using Perl Telnet module

Perl SSH Interface

Python SSH

Python Telnet module


Do all the methods above need installation ? Because once the script is created, i will have to integrate it into excel macro for public usage. So if the rest do not have the relevant protocols installed, they wouldn't be able to use it. It would be best if windows batch files could do the job.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script to convert dos to UNIX in Solaris

Hi Team, I am trying to implement a script in Solaris, that required to find the list of files inside directories and convert those to dos2unix conversion, Can someone please help here.. Below is the example of scenario.... (1 Reply)
Discussion started by: Logics123
1 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

4. Shell Programming and Scripting

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... (14 Replies)
Discussion started by: rookie2785
14 Replies

5. 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

6. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

7. Windows & DOS: Issues & Discussions

Hide svchost.exe (dos prompt) when executing scheduled task

hello everyone. I created a java program that will pop up a dialog, and scheduled it as a task. Everything works fine except when the scheduled java program runs and the dialog pops up, there is another dos prompt (svchost.exe) hanging behind the dialog box and doesn't go anywhere until the java... (0 Replies)
Discussion started by: milhan
0 Replies

8. Shell Programming and Scripting

execute shell file on DOS prompt

I have installed cygwin on my computer having windows 2003 server as operating system. The following command works fine on DOS console: bash launch_update.sh Is there any way, that i could run the above shell file, just by typing its name on DOS prompt, in the same way as batch files are... (1 Reply)
Discussion started by: mmunir
1 Replies

9. UNIX for Dummies Questions & Answers

Can Unix (Solaris) execute a dos .bat script?

I did a search and found lots of questions/comments about how a dos script could execute Unix but not the other way round. If it's possible, I'd like the link to a post/site that would show me the way. Thanks. (4 Replies)
Discussion started by: BCarlson
4 Replies

10. UNIX for Dummies Questions & Answers

?Using Unix commands in Microsoft (Windows') DOS Prompt?

I ran a search for "Unix Dos" in the search field box and checked a few pages' results but did not find what I was looking for. I am trying to find out if there are choices of applications that would enable using Unix commands inside a Windows environment, particularly the DOS Prompt. The only... (2 Replies)
Discussion started by: HLee1981
2 Replies
Login or Register to Ask a Question