Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
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…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

735 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