Solved

Convert DOS Batch file into Shell script

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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