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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running external command in DOS

Status
Not open for further replies.

perldoubt

Technical User
May 18, 2008
5
0
0
US

Hi,

Please help me.

I am tryinhg to run an external command on DOS using perl script.

Backtics do not work.

General syntax of the command is:


bl2seq -p programname -i firstfilename -j secondfilename -o

<outputfilenanme>

which in my program is :

C:\\xxx\\xxx\\xxx\\bl2seq\\bin\\bl2seq -p blastp -i C:\\xxx\\xxx\\xxx\\xx\\FH1 -j C:\\xxx\\xxx\\xxx\\xxx\\FH2 -o C:\\xxx\\xxx\\xxx\\xxx\\FH1.txt");

I am trying to call this using system();

Please help me.

Thanks,
perldoubt
 
Have you tried using quotes?

system("Command to run");

or you could save the command to a variable and then call the variable in the system command

Code:
command = "Command that you would like to run here";
print $command; # Make sure output looks correct when printed
system($command);
 
No man,
Its not working.
look at this..

this command at DOS works well.

bl2seq -p blastp
-i gi_57652444_r3.faa
-j gi_57652446_r2.faa
-o pp.txt
but when I write a script:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#!/usrlocal/bin/perl

$command = "bl2seq -p bl
astp -i gi_57652444_r3.faa -j gi_57652446_r2.faa -o pp.txt";
print $command."\n";
system($command);

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bl2seq -p bl
astp -i gi_57652444_r3.faa -j gi_57652446_r2.faa -o pp.txt
[NULL_Caption] ERROR: Arguments must start with '-' (the offending argument #3 was: 'astp')

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any suggestions?

 
Code:
$command = "bl2seq  -p [red][b]bl
astp[/b][/red] -i gi_57652444_r3.faa    -j gi_57652446_r2.faa  -o pp.txt";
Is the section in red really broken up with a new line? I suspect that's not helping anything.
 
i suspect that rharsh is right because the error mentions starting with astp not blastp.

Also in your original code.. if you surroung everything with a single quote you don't have to use double black slashes. You also can just use forward slashes as dos/windows won't care. You should still use single quotes though. Unless there's a variable in those double quotes somewhere your just having perl do more work than necessary.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
the 'system' function expects to get your command and it's arguments in a list. I think passing all the arguments as pieces of a STRING will cause the function to barf.

Sorry, but, I don't have time to play with it to put an example together.

See c:\>perldoc -f system



'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Here's an example. It's not tested, of course, as I dont have bl2seq on my system...
Perl:
use strict;
use warnings;

my $file1 = "gi_57652444_r3.faa";
my $file2 = "gi_57652446_r2.faa";
my $outfile = "pp.txt";

system('bl2seq -p blastp -i', $file1, '-j', $file2, '-o', $outfile);

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 

Thanks Steve,That was perfect.

storing assigning filenames to a string var is an excellent idea.

IT's working now.
Thanks a ton.

Aparna
 
You also can just use forward slashes as dos/windows won't care.

DOS does care. The forward slash is an option switch in DOS, not a directory path, like it is in Windows.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thats right.

I used \\ to define path.
/\did'nt work.

 
DOH!! :)
Thanks Kevin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Try to escape "-" with "\"

=> "\-option" when specifying one option.

Hope it helps

dave82
 
How many sequences are you comparing?
I used the same program. bl2seq is fine for maybe a couple of sequences. If you have a ton of sequences it's probably a better idea to use blastall. instead of taking 60 days to do a billion comparisons, blastall did it in 5 hours.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top