Solved

Convert DOS Batch file into Shell script

Posted on 2011-03-21
3
803 Views
Last Modified: 2012-06-27
Hi, I have a Dos Batch file and I want to convert it into Linux script because I may run the batch file in the different enviroment. Please ignore the -- or -, it is the option of the commerical software PLINK.

set PLINK=\\Sun\GroupData\APP\plink\plink.exe
set src=\\Sun\GroupData\ABC\Englind\Impute
set pheno_path=\\Sun\GroupData\ABC\XYZ\plink_input
set pheno=%1
set chr=%2

if not exist %pheno%\nul mkdir %pheno%
%PLINK% --bfile %src%\bed\chr%chr% ^
 --pheno-name logh ^
 --assoc ^
 --qt-means --out %pheno%\chr%chr%

Open in new window


Thanks
0
Comment
Question by:zhshqzyc
  • 2
3 Comments
 
LVL 3

Assisted Solution

by:gopisera
gopisera earned 62 total points
Comment Utility
Instead of set operator in windows scripting  in linux  use export

e.g.,
export  src=\\Sun\GroupData\ABC\Englind\Impute

and you can wirte the if condition similar to below

if [ -nf  /x/x ]; then
echo "Hai"
els
echo "Hello"
fi

if the file /x/x exists display Hello else Hai.

You have to convert manually, line by line from windows to Korn shell scripting
 
0
 
LVL 19

Accepted Solution

by:
simon3270 earned 63 total points
Comment Utility
I assume that there is a UNIX/Linux equivalent of the "plink.exe" command, presumably called "plink".  It woudl be easiest to mount \\Sun\Groupdata onto a local directory before you start (as the root user):
mkdir /mnt/groupdata
mount //Sun/GroupData /mnt/groupdata

Open in new window

Then the script would be as follows, with the same 2 parameters as the DOS one:
PLINK=/mnt/groupadta/APP/plink/plink
src=/mnt/groupdata/ABC/Englind/Impute
pheno_path=/mnt/groupdata/ABC/XYZ/plink_input
pheno=$1
chr=$2

if [ -d $pheno ]; then
  mkdir $pheno
fi
$PLINK --bfile $src/bed/chr${chr} \
 --pheno-name logh \
 --assoc \
 --qt-means --out $pheno/chr${chr}

Open in new window

0
 
LVL 19

Expert Comment

by:simon3270
Comment Utility
Why do you always see errors *after* posting?  :-(

The if test should be "if [ ! -d $pheno ]" (missed !)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

6 Experts available now in Live!

Get 1:1 Help Now