New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent result when trying to echo to a file #798
Comments
Edit: I wrapped some of your text in code blocks in the description |
I'm a bit confused (this is a lot of text). @drkarma Could you clarify:
In general, I would recommend trying something like: shell.config.silent = true; // Don't let echo print to the terminal
shell.echo('my test to echo').to('myFile.txt'); // This is cross-platform |
Hi sorry to confuse you. Doing what you state e.g. shell.echo(myPubKeyRSA).to(myPath + 'pub_key_rsa.txt'); (and I slap my forehead for not figuring that out myself) solves my problem...but the reported issue remains. I.e. this works var myKeyValue = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfF4OIX2DIUZJyr7pNqblA49C1hCWzbKZHCSi7161FvfpHJYjeL8BQQPCyhNJKN6W39iEkHbcnqdU03jImEkQT2cnOxN5LBIc0wVYtJvT+KzVj4y3bqELnjJqJjEwXZZfmBsJz4l1pnQ8mjJ0kgcgBCZCV2A9Kg6EepRoRgMbM2mrXTuMYdp+rRqrJUn7X6HBZGLS23t5ty/5B9704kDzTj+ATwZLulbuNHsBs4galz6U+5pveYseKMtRubJjCT54jCGXuyHIy6Imtetpd2KsI9pvZGvsu2STT2eX0y8lG+RNbMQuUtnhant203vog3SkpfxRhPqO8JgmGuQ64Lpy3";
var myPath = 'phonebook/';
shell.exec('echo ' + myKeyValue + ' > ' + myPath + 'thekey.txt'); But when the same thing done when processed in the first code snip does not. i.e. the following var myPath = 'phonebook/' + myHostname + '/';
shell.mkdir(myPath);
... skipped code
shell.exec('echo ' + myPubKeyRSA + ' > ' + myPath + 'pub_key_rsa.txt');
... skipped code But your suggestion sorted it out for me so I am happy, but I still think it is odd that there is an inconsistency. |
Great news! 🎉 I can't quite figure out what issue you were seeing with |
Closing, because we can't reproduce (and the reporter has a workaround). |
Node version (or tell us if you're using electron or some other framework):
v7.10.0
ShellJS version (the most recent version/Github branch you see the bug on):
shelljs": "^0.7.8"
Operating system:
Ubuntu 16.04
Description of the bug:
Scenario:
Getting a POST from a cloud-init "phone home" function that provides some data that I want to echo into separate files per data
Bug:
There seems to be an inconsistency, because the code below does only produce correct value in the cases where the echoed string variable is short. However if I would take one of the longer string variables e.g. 'myPubKeyRSA' and create a test script like the second example in the code that works properly.
When the execution fails to echo to the file then the echoed value spills over and is displayed in the node js console
Example ShellJS command to reproduce the error:
This script will NOT put long strings into the file but the file is created
console output when the code above is triggered
checking file in terminal
folderlisting
This script will put value into a file even if the variable holds a long string
Output in terminal
The text was updated successfully, but these errors were encountered: