Solved

Convert DOS Batch file into Shell script

Posted on 2011-03-21
3
807 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
ID: 35185916
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
ID: 35187985
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
ID: 35191051
Why do you always see errors *after* posting?  :-(

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

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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