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
Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
extend monitor issues 6 44
Location of files for Quick Access Toolbar (QAT) settings in Office 2010 3 52
Windows Restrict installation 11 38
List out file 4 27
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

856 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