Solved

How to call Unix shell script from MS-DOS Batch file

Posted on 2004-04-23
6
8,027 Views
Last Modified: 2013-12-28
Hi,

Through MS-DOS Batch I am FTPing file into Unix Server. As soon as It transfered  to Server, I want to run a Shell script from Batch file to process that file.
Is there any solution to run shell with out using crontab or any other schedulers.

I mean, I want activate shell script from Batch file.

Thanks in advance.

Regards,
Linga Reddy

 
0
Comment
Question by:glingareddy
  • 2
6 Comments
 
LVL 41

Expert Comment

by:graye
ID: 10903987
If assume you mean, run a unix-style shell script from a WinNT Command Prompt (not really a 16-bit MSDOS session?)

Yes, there are some free and commerical version of popular Unix shells (and the assorted commands) for WinNT.  I've been using MKS Toolkit for many years.  Kinda expensive, but very complete set of Unix tools.

http://www.mks.com/
0
 
LVL 3

Accepted Solution

by:
flakier earned 20 total points
ID: 11111572
In order to execute a program or script on the remote unix box you will need to use ssh which should be running on your unix box.  On the windows side, you will connect using a little util that comes with the PuTTY terminal client.  Grab the windows installer from
<a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
</a>

Instructions for how to use plink are here:
<a href="http://the.earth.li/~sgtatham/putty/0.54/htmldoc/Chapter7.html#7">
http://the.earth.li/~sgtatham/putty/0.54/htmldoc/Chapter7.html#7
</a>

Basicaly you would just call plink right after your ftp commands are done with.  Remember that you can string commands together with && at least in the bash shell.  Using && instead of ; makes sure that everything finishes successfully before the next command is executed.

Cheers,

~Jason

--
0
 
LVL 3

Expert Comment

by:flakier
ID: 12308682
I stand by my initial recomendations.

Here's some aditional advice for the archives:

Another possible way of doing this is to write a script in perl (or python maybe) that implements a telnet or ssh client.  In perl I've used the Net::Telnet module and it's not to hard to set up a connection and have it run a command or two.  Basicaly do something like this:

[code]
use Net::Telnet();

$timeout  = "240";  # About how many seconds command takes to run
$prompt  = '/WhatTheShellPromptLooksLike/'; # single quotes works best
$cmd       = "/path/to/shellScript";

# Set up the session
$telnet = new Net::Telnet();

# Initiate the connection
$telnet->open("$host");

# Send our command
@output = $telnet->cmd(String    => "$cmd",
                                     Prompt  => "$prompt",
                                     Timeout => "$timeout");
# Close Session
$telnet->close();
[/code]

Note that the array "@output" contains what your command outputs so you will probably want to parse that to see if the command was successful or not.  I'm sure there's a module to do a similar action via ssh instead of telnet.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now