Solved

Convert DOS Batch file into Shell script

Posted on 2011-03-21
3
804 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

21 Experts available now in Live!

Get 1:1 Help Now