Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creatign a text file usign a batch file 1

Status
Not open for further replies.

andysi

Technical User
Mar 11, 2004
5
US
First apologies for my ignorance

I'm trying to create a batch file which will create the following text file

Input_Pedigree_File=pedin.52821
Input_Locus_File=datain.52821
Input_Map_File=map.52821
Input_Untyped_Ped_Option=2
Analysis_Option=1
Analysis_Sub_Option=2
Chromosome_Single=21
Default_Outfile_Names=yes

I have no problem creating the first three lines (using echo...I allocated the numbers 528 and 21 as %1 and %2 as these are the only variable numbers in this file) but cannot get lines 4 5 and 6 created...alwyas seems to drop them or lose the 1 or 2 (I guess this is something to do with =)

Any help is much appreciated
 
Hi andysi

First of all welcome to Tek-Tips. To get the best from these forums you should read faq222-2244 first. For this question:

1. Where have you got to so far?
2. Which BASIC are you using?
3. How many of the answers are variables and how do you want to input them?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
HI John, appreciate your comments. So this is intended to be a .bat file running in WindowsXP from the command line. The .bat is used to generate a file which allows me to automate linkage analysis (looking for genes that cause disease). So far I have:

echo Input_Pedigree_File=pedin.%1%2> megabatch.txt
echo Input_Locus_File=datain.%1%2>> megabatch.txt
echo Input_Map_File=map.%1%2>> megabatch.txt
echo Input_Untyped_Ped_Option=2>> megabatch.txt
echo Analysis_Option=1>> megabatch.txt
echo Analysis_Sub_Option=1>> megabatch.txt
echo Chromosome_Single=%2>> megabatch.txt
echo Default_Outfile_Names=yes>> megabatch.txt

The lines
echo Input_Untyped_Ped_Option=2>> megabatch.txt
echo Analysis_Option=1>> megabatch.txt
echo Analysis_Sub_Option=1>> megabatch.txt

are the ones causing me a problem, and also
echo Chromosome_Single=%2>> megabatch.txt

when %2 is 1 or 2

%1 will be a number from 1-1000

thanks
 
It seems to work OK if you put spaces either side of the = sign

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
thanks for the reply John, I appreciate it. I just gave this a go and still doesn't seem to work...

When I run this bat file from the command line followed by 528 and 18 (my variables)

echo Input_Pedigree_File = pedin.%1%2> megabatch.txt
echo Input_Locus_File = datain.%1%2>> megabatch.txt
echo Input_Map_File = map.%1%2>> megabatch.txt
echo Input_Untyped_Ped_Option = 2>> megabatch.txt
echo Analysis_Option = 1>> megabatch.txt
echo Analysis_Sub_Option = 2>> megabatch.txt
echo Chromosome_Single = %2>> megabatch.txt
echo Default_Outfile_Names = yes>> megabatch.txt

gives an output to the megatbatch.txt file of:

Input_Pedigree_File = pedin.52821
Input_Locus_File = datain.52821
Input_Map_File = map.52821
Analysis_Option =
Chromosome_Single = 21
Default_Outfile_Names = yes

cheers.
 
Sorry I missed out the space required between '1' and '>>' and the space between '2' and '>>'. Try this (cut&paste into NotePad):
Code:
echo Input_Pedigree_File = pedin.%1%2 > megabatch.txt
echo Input_Locus_File = datain.%1%2 >> megabatch.txt
echo Input_Map_File = map.%1%2>> megabatch.txt
echo Input_Untyped_Ped_Option = 2 >> megabatch.txt  
echo Analysis_Option = 1 >> megabatch.txt
echo Analysis_Sub_Option = 2 >> megabatch.txt
echo Chromosome_Single = %2 >> megabatch.txt
echo Default_Outfile_Names = yes >> megabatch.txt

Using 528 and 21 produced this:
[tt]
Input_Pedigree_File = pedin.52821
Input_Locus_File = datain.52821
Input_Map_File = map.52821
Input_Untyped_Ped_Option = 2
Analysis_Option = 1
Analysis_Sub_Option = 2
Chromosome_Single = 21
Default_Outfile_Names = yes
[/tt]
Careful use of spaces is vital in batch files

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
thanks for your help johnwm

I was still having problems with this because the spaces were an issue in the text file produced (the text file is a batch file for a genetics program).
I managed to get around this using ^ although it took me a while to figure out that ^ was the "ignore" character I was looking for:

echo Input_Pedigree_File=pedin.%1%2> megabatch.txt
echo Input_Locus_File=datain.%1%2>> megabatch.txt
echo Input_Map_File=map.%1%2>> megabatch.txt
echo Input_Untyped_Ped_Option=^2>> megabatch.txt
echo Analysis_Option=^1>> megabatch.txt
echo Analysis_Sub_Option=^2>> megabatch.txt
echo Chromosome_Single=^%2>> megabatch.txt
echo Default_Outfile_Names=yes>> megabatch.txt

again, thanks for your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top