question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

truffle exec with arguments

See original GitHub issue

Can I pass argument to js script executed using “truffle exec”?

Example:

script.js module.exports = (callback, arg) => { console.log(arg); callback(); }

exeucution truffle exec “./script.js” “argument”

expected output argument

actual output undefined

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
RyanRHallcommented, Aug 19, 2019

bump to reopen. It’s quite annoying to deal with potential variations in executing like:

truffle exec script.js arg1
truffle exec script.js --network live arg1
truffle exec script.js --network live --compile arg1
truffle exec script.js arg1 --network live --compile

These should really all do the same thing as far as the script is concerned. It’d be nice to make it easier on the developer and provide an array of arguments. I’d support a function signature that looked like this…

module.exports = function(callback, CLIArgs) {}
2reactions
gnidancommented, Apr 9, 2018

You can use process.argv for this, but note the offset - I believe this will be interpreted as node /path/to/truffle/cli.js exec <args...>, so args start at index 4.

Closing this. Feel free to open a new issue for feature requests to expand on this, if it doesn’t meet your needs. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass command line arguments in truffle exec
How to pass command line arguments in truffle exec · Your are on node, so you can use process.argv or any other library...
Read more >
Command line options - Truffle Suite
Passing no arguments is equivalent to truffle help , which will display a list of all commands and ... Execute build pipeline (if...
Read more >
Truffle commands - DApp develop framework | PlatON
Passing no arguments is equivalent to platon-truffle help , which will display a list of ... platon-truffle exec <script.js> [--network <name>] [--compile].
Read more >
truffle exec <script.js> - Fig.io
Arguments ; script.js, JavaScript file to be executed. Can include path information if the script does not exist in the current directory. (required) ......
Read more >
Command reference - Truffle Suite
Execute build pipeline (if configuration present) $ truffle build ... truffle exec /path/to/my/script.js ... The @ version parameter syntax is optional.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found