Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7913361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:49:30+00:00 2026-06-03T13:49:30+00:00

I’m kinda new to running Perl on windows, and I’m having some problems with

  • 0

I’m kinda new to running Perl on windows, and I’m having some problems with the system command while trying to run avrdude.exe to upload a HEX file to a Atmel Microcontroller. These are the Perl commands I am using to execute the command:

$AVR_CMD = "\"".$AVR_DUDE."\"" . " -C" . "\"".$AVR_DUDE_CONF."\""; 
$AVR_CMD .= " -v -v -v -v -patmega2560 -cstk500v2"; 
$AVR_CMD .= " -P\\\\.\\".$PORT;
$AVR_CMD .= " -b115200 -D -Uflash:w:". "\"".$HEX_FILE."\"". ":i";

system($AVR_CMD);

Now, I am printing the final command to ensure that it is OK, and it seems to be. However, there seems to be some sort of permissions problem in the actual execution. When I copy and paste the printed command into the windows terminal, it results in this:

avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is BLOCKED FOR SO

         Using Port                    : \\.\COM4
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 115200
avrdude.exe: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

Which is evidently avrdude being run with the correct parameters. However, when I run this command using system(), I receive this output:

avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is BLOCKED FOR SO

         Using Port                    : \\.\COM4
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 115200
avrdude.exe: ser_open(): can't open device "\\.\COM4": Access is denied.
avrdude.exe done.  Thank you.

This leads me to believe that there is some sort of permissions difference between running a command in CMD and running it through system(). If anyone could offer some insight on this or give me any tips to remedy this problem it would be greatly appreciated. Thanks beforehand.

EDIT: I have written a Perl script that calls avrdude.org after sending a hard reset to the Atmel (based on some code in this thread):

#!/usr/bin/perl -w
use Win32::SerialPort qw( :STAT 0.19 );
use FindBin qw($Bin);

#Do port reset
foreach (@ARGV)
{
    if ($_ =~ /-P\\\\\.\\(.*)/)
    {
        print "Found -P argument - ";
        print ("Resetting DTR on " . $1 . "\n");
        $P1 = new Win32::SerialPort ($1);
        $P1->pulse_dtr_on(1000);    
        last;
    }
}

select(undef, undef, undef, 0.1);
print ("Executing avrdude\n");
system($Bin . "/avrdude.org " . join(" ", @ARGV));

However, this still has the same problem. If the Perl system() call has the same permissions as running through the command line, then why can I execute the command in the command line, but COM4 access is restricted when I call the same EXE from Perl? :S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:49:32+00:00Added an answer on June 3, 2026 at 1:49 pm

    system can take either a string argument, like you did, or a list of arguments. In the latter (recommended) case, the shell handles the quoting for you. So, just make a list of the arguments and pass it. Something like this:

    my @args = ($AVR_DUDE, " -C", $AVR_DUDE_CONF, 
               qw(-v -v -v -v -patmega2560 -cstk500v2), "-P\\.\.$PORT", 
               qw(-b115200 -D -Uflash:w:), $HEX_FILE, ":i");
    system(@args);
    

    Note that you do not need to put variables outside double quotes. And you can use other quoting methods to avoid having to escape quotes. E.g.:

    "\""
    

    Can be written in any of these forms:

    '"'
    qw(")
    q(")
    qq(")
    q#"#   # etc
    

    See perldoc perlop for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.