Naked.toolshed not sending all the parameters info

Viewed 118

Here is a little example of my code in python:

from Naked.toolshed.shell import execute_js, muterun_js

caption=str("fsf sfsggs")

link="sggdhbwdhsrh"

print(caption)

arg_in = f"{link} {caption}"

response = execute_js('C:/Users/Me/AppData/Roaming/npm/node_modules/t.js', arg_in)

And then the js code that prints those parameters only to see if the script recibed the info as it should:

var link = process.argv[2]

var caption= process.argv[3]

console.log(caption)

But then I only get the first word in the cmd:

fsf
1 Answers

Command line arguments are delimited by spaces, so the caption value is getting split into 2 args.

You're only logging process.argv[3], which is actually the 4th argument of 5. You can see them all with console.log(process.argv)...

[
  'C:\\Program Files (x86)\\nodejs\\node.exe',
  'E:\\proj\\so\\t.js',
  'sggdhbwdhsrh',
  'fsf',
  'sfsggs'
]

The array element indices are zero-based (of course!). So sfsggs is in process.argv[4]

If you want to pass the caption as one argument containing a space, then in the Python you can enclose in speech marks " like so...

caption='"fsf sfsggs"'
Related