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 8015005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:07:21+00:00 2026-06-04T20:07:21+00:00

I successfully executed commands and .bat files in command prompt using XUL by this

  • 0

I successfully executed commands and .bat files in command prompt using XUL by this code:

Components.utils.import("resource://gre/modules/FileUtils.jsm");

var env = Components.classes["@mozilla.org/process/environment;1"]
                    .getService(Components.interfaces.nsIEnvironment);
var shell = new FileUtils.File(env.get("COMSPEC"));

var args = ["/c", "cd C:/ffmpeg/bin & record.bat"];

var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
process.init(shell);
process.runAsync(args, args.length);

But now I changed .bat files to .sh files to run for Ubuntu and need to run commands in terminal by using same code, so I need to change environment variable “COMSPEC” to something which works for terminal, I found that it is “TERM” but didn’t work.

Is there any other environment variable or way to do this task?

  • 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-04T20:07:23+00:00Added an answer on June 4, 2026 at 8:07 pm

    The command to run shell files on Linux is fixed – it is always /bin/sh. So you would do:

    var shell = new FileUtils.File("/bin/sh");
    var args = ["-c", "record.sh"];
    

    This isn’t quite the correct approach – if you wanted to do it absolutely correctly you would look inside the script file and parse the first line (which is usually something like #!/bin/sh). And in the general case you wouldn’t check the file extension but rather whether the file is executable (on Unix-like systems this is completely independent of the file extension). But I guess that you aren’t very interested in the general case.

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

Sidebar

Related Questions

Platform: Windows Grep: http://gnuwin32.sourceforge.net/packages/grep.htm Python: 2.7.2 Windows command prompt used to execute the commands.
From bash terminal, I successfully executed the following command. curl -v -L -F file='@/var/www/dev/public_html/sixties.mov'
We're using TeamCity's command line build runner to call a bat-file. The bat-file builds
Here i used below in code on linux. using cp command in system function.
I execute a BIDS package using command line (.bat). The package has a script
I have successfully executed a project in a system,with Android 2.2... When i ran
I have created many TestProjects with Visual-Studio-2010 Ultimate . All tests were executed successfully
I am able to successfully execute this on windows: builder = new ProcessBuilder(cmd.exe, /c,
I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this
after successfully building my application the start fails because it relies on config files

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.