Solved

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

Posted on 2004-04-23
6
8,025 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

763 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

12 Experts available now in Live!

Get 1:1 Help Now