Incorrect usage of command in JavaScript with cordova-plugin-shell

I'm looking to simulate screen tapping in my Capacitor app. I've been using cordova-plugin-shell, which works fine with a simple command like:

window.ShellExec.exec('uptime', function(res){console.log('exit status: ' + res.exitStatus)console.log('cmd output: ' + res.output)})

However, when I try to use other commands, I keep getting an exit status of 100 (indicating a wrong command).

The function I need to use is:

window.ShellExec.exec('input tap 500 500', function(res){console.log('exit status: ' + res.exitStatus)console.log('cmd output: ' + res.output)})

This command works on PC without requiring root access, but for some reason, it doesn't work from within my app. Could the issue be related to whitespaces in the adb command?

Answer №1

To ensure success, attempt running the command as a root user.

 window.ShellExec.run(['su', '-c', 'input tap 500 500'], function(result){
      console.log('exit status: ' + result.exitStatus)
      console.log('command output: ' + result.output)
 })

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method to inform JavaScript about PHP server-side login and logout functionalities?

Looking for a way to notify users conveniently, without compromising security: I have JavaScript set up to poll for new information while a user is logged in. I need it to stop polling when the user logs out. What's the best approach to inform JavaSc ...

The DOM seems to be producing NaN when receiving user input

Currently, I am in the process of developing a depreciation calculator that utilizes user input fields to generate an alert with the resulting value. When I set the variables to predefined test values without incorporating user input, the calculator funct ...

Repetitive NodeJS event triggers within Electron-React application causing unexpected behavior

In my custom software package (referred to as PACKAGE_A), I have implemented various automated tasks using a node script. This package includes a Notifier module that creates and exports an EventEmitter. (The entire project is structured as a Monorepo) co ...

What is the best way to incorporate JavaScript files into a Java application?

Java applications execute Javascript code. However, the Jquery library is too lengthy to be accommodated in a String variable. I am able to read jquery.js from a file but unsure of how to bundle it within a .jar file. ...

Troubleshooting Service Worker Registration Issue on IOS with ReactJS PWA and Firebase

Struggling to integrate web push notifications into a React-based PWA, I've encountered challenges with updating the service worker, particularly on iOS. Clicking the notifications enable button leads to a delay in SW update and registration, followed ...

Initiating an AJAX request to communicate with a Node.js server

Recently, I started exploring NodeJS and decided to utilize the npm spotcrime package for retrieving crime data based on user input location through an ajax call triggered by a button click. The npm documentation provides the following code snippet for usi ...

Tips for formatting numerical output in EJS by rounding the value

I am displaying a value in EJS and I am looking to format it to show fewer decimal places. This is related to the EJS engine on the frontend. Value displayed: 4.333333333333333 I want it to be displayed like this: 4.3 The EJS code snippet used: <p cl ...

Assigning input array values with jQuery

I'm currently working on incorporating HTML input arrays. <input type="text" name="firstName[]" id="firstName[]"> I also need to populate another form that looks like this: <form id="tempForm"> <input type="text" name="userName" i ...

Unable to establish a connection through the socket

I am currently following a tutorial on setting up a simple WebSocket between client and server in JavaScript. I have reached the point where the author mentions: At this point, if we refresh our webpage we can see the “Made socket connection“ and a u ...

What is causing the Access-Control-Allow-Origin error when using axios?

I have a simple axios code snippet: axios.get(GEO_IP) .then(res => res) .catch(err => err); In addition, I have configured some default settings for axios: axios.defaults.headers["content-type"] = "application/json"; axios.defaults.headers.common. ...

JavaScript Slider Carousel for React framework

Can anyone assist with this? I need to rewrite everything in a standard algorithm, not as it is currently. I have three elements and I would like to create an infinite loop carousel where the next button takes me back to the first element when I reach the ...

Exclude previous dates from the front end of ACF date picker

I am using Advanced Custom Fields to post job ads, and I have incorporated a date picker field for the end date of each job ad. <?php if (have_rows('jobs', 'option')): ?> <?php $now = time(); ?> <div i ...

The mobile-responsive dropdown navigation bar functions well on browsers with small widths, but does not work properly on my phone

I am experiencing an issue with the mobile responsive dropdown navigation bar on my website. It works perfectly fine on a small width browser, but when I try to open it on my phone, nothing happens. This is puzzling me as I am new to making websites respon ...

What causes the temporary halt of context execution in the eventloop framework?

Presenting the code immediately: setTimeout(() => console.log("next macro")); /// next macro Promise.resolve().then(() => gen.next()) /// microtask inside, #2 const gen = (function*(){ console.log("Hello"); yield; /// #3 console.log("W ...

There is no value inputted into the file

I'm facing a small issue while trying to retrieve the value from my input of type="file". Here is the code snippet: <tr ng-repeat="imagenDatos in tableImagenesPunto | filter: busquedaDatosPunto " > <td>PNG</td> <td>{{imag ...

What steps can I take to ensure a uniform design across all web browsers?

As I approach the end of fixing the repetitive alarms on my small learning project, I can't ignore the bugs that still remain. Although this is just a weekend project, I am slowly working to correct them. The main issue I'm facing now is the inco ...

Possible rephrased version: "Encountering a Jquery clash

It appears that the issue causing my problem may be a Jquery conflict. Please correct me if I am wrong after reviewing the information below. I am new to Jquery and attempting to add a dropdown plugin to a website. The attempt is successful, but an existi ...

jQuery's AJAX functionality may not always register a successful response

Below is the code snippet I am currently working with: $(".likeBack").on("click", function(){ var user = $(this).attr("user"); var theLikeBack = $(this).closest(".name-area").find(".theLikeBack"); $.a ...

Python Selenium encounters a blank return issue following a page refresh

Currently utilizing Selenium Python in conjunction with BeautifulSoup for web scraping purposes. My primary objective is to extract the page's html content post the activation of the 'Live' button. While I am able to successfully trigger the ...

Mongoose has a tendency to duplicate the mongodb collection within a single instance

For educational purposes, I am developing a simple todo list application using custom routing functionality. When a user enters a custom route, I check if a document with that name exists in the database. If it does not exist, I create one. However, I am e ...