Solved

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

Posted on 2004-04-23
6
8,049 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
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 …

726 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