Raspbian redirect console log to usb file - javascript

I am new here, but I have spent several days in and issue that I have not solved yet.
This is what I want to achieve:
I would like to redirect the console logs to a USB file directly.
I have a shell script to be launched automatically when booting the raspberry (this process works). The script executes a javascript file.
I need to remove the USB drive directly, with the raspberry pi still powered on, and the log file remaining in the USB drive.
This is what I tried:
Redirect it directly with expression like: "sudo node node_modules/sensortag/.. > /media/USBname/Data.txt" (it shows me 'access denied'), but the first part of the expression works fine if executed without the redirection part.
I have tried to change permissions for USB directory, and still the same problem.
I have tried to execute the previous command in the terminal (not with the script) and it only works if "sudo su" command is entered before the instruction (but it does not work only with "sudo" command and I do not know how to insert "sudo su" command in the script). I have tried many different options.
Do you know why I have this error? and could you tell me how to solve it?
Another option that I can try, but not yet because I do not have it clear, is to modify the javascript file to redirect the console log to a USB file. Could you tell me how to do it?
Thanks a lot. I have took a look to many different forum threads but I am not able to solve this problem. I hope you can guide me on it.

Related

Looking for a technology/code in java or other maybe to sync files from browser or https

https://github.com/deanhiller/webpieces is a platform that you can write code in java without rebooting the server via it's DevelopmentServer.
Now, to avoid the cycle of fix code, deploy to cloud, test, fix more code, deploy to cloud to test, I would like to just sync changed files to the cloud container so that the cycle becomes
change code
test
no more deploying and since you are just uploading human changes, it's FAST. Now, webpieces is a webserver that hosts a website or json api or whatever. I am thinking of 2 ways of doing this but not sure the technology is there?
Go to webpage on the cloud server and input local source directories to monitor
Locally, just run a program webpiecesSync configuring source directories and the json api to hit on the cloud instance
Number 2 has an extreme advantage over #1 in that I can register for async file notification of changes so as you change a file, the sync uploads it to the cloud and webpieces DevelopmentServer just saves the file to the needed location and when you hit the webpage with the change, the DevelopmentServer does the work of recompiling when needed.
I am not sure #1 can even come close to #2, but if anyone knows of a technology there, javascript or whatever that could maybe do this, I am wondering if I could make a wizard in the DevelopmentServer sync plugin (if I had one) that would then just keep up to date with changes of the directories and grab those files(assuming the user gives it permission somehow). I am very lost if #1 is even feasible?
Any ideas/guesses greatly appreciated.
thanks,
Dean

RequireJS - Module name "wget" has not been loaded yet for context

I'm trying to run an HTML file with JavaScript inside of it. In the JavaScript I'm trying to run is a program called wget. It downloads information from a website. I used it on CMD and in a batch file to get data from an xml that is hosted locally on my computer. Now I am trying to run wget so it runs from an HTML file. (the panel.html for the twitch panel extension), however I have been having a time just making the thing run.
I have been fiddling around, and the issue I now face is when I try to run the HTML in Chrome web browser the inspector says, Module name "wget" has not been loaded yet for context.
Screenshots:
HTML:
Error from Chrome:
(Click image to enlarge)
Installed wget from cmd:
I tried to read this for hours, and I don't understand it at all. In fact I don't think the issue in the link is the same issue as mine, but this is what every search keeps coming up with. I don't understand the whole dynamic thing or why they are even using the word "dynamic" for. It just seems like they can't use require because it doesn't work against paths, however I am not trying to define a path. I just want wget to work from this HTML file. I'm annoyed that I can't find anything on this exact problem. Every problem I have seen like this doesn't have a basic example of var wget = require('wget');
I just need what's in my JavaScript or HTML script tag to work.
I downloaded the require.js file and put it into the HTML as a script tag. From here it should just work. I already downloaded wget from cmd so it's on the computer somewhere. I also put the .exe in the same folder as the .html and the require.js.
Also I read somewhere that another reason this doesn't work is because wget is "loaded" or something like that. In that case can someone tell me how to "load" wget into the HTML or JavaScript first so that this error goes away? The basic wget example I found online is:
Here is the HTML file:
I'm not using a path, I just want wget to work from JavaScript. The wget example shows that it uses require. If I don't need require then please provide an example of how I can use wget in JavaScript without require or how to make this error go away.
I've been trying to figure out the best way to get the status information from my VLC player and put it into an HTML file so I can use that as a Twitch extension on my Twitch channel. VLC media player has a status.xml when you run it as a http server. I can only access the localhost:8080/requests/status.xml from a browser because it has basic authentication where I have to put in my user name, so I use wget to put in my password and download the status.xml back to my computer as another copy that isn't setup with authenitcation. Then I can use that download status.xml's information to post what music is playing on my VLC player. The problem is I need wget to pull the information from the localhost:8080/requests/status.xml file from the html file so that whenever its ran, the status.xml gets update with the new information and this the html will post the most current thing playing on my VLC player.

Logging properties of Node.js

I'm starting on a project using Node.js, and I'm running into some issues with it's logging. I'm completely new to Node.js, but my understanding is that using console.log([data]) should print out the value of [data] to the server console.
I see this occurring how I expect in several places in this project, but when I try to add additional logging, nothing is prompted out to the console window.
I've noticed that all of the files where logging is working are under a specific folder, while the bulk of the code is under another.
Does anybody know what might be the cause of these not to print out into the console? I've also tried console.error([data]) and console.warning([data]) to see if it might be due to an error but that also didn't work.
Without having your actual code, this is just a guess:
The files where the logging is working are the Javascript files for the server. The "bulk" of the code may be the client code (I guess so because you're saying in the comments of your post that you inserted a working alert, which is a browser thing), so your logs go to the browser not to the server.

SP page deployed, but the content is old

I have a simple setup - SharePoint Foundation Server and Visual Studio 2013 Professional installed on this server. Everything worked fine. Until... I don't know why, but deployment stopped refreshing content on the page.
I have some javascript code on my page (inside aspx page or in external js file). When I change it (e.g. output sth else to console) I still see the effect of some previous build. It looks like deploy operation does nothing. The most puzzling part I think is when I click Debug button. One would expect it to work at least there. But it doesn't.
Two other developers working on the same environment (same server) have no problems with changing their JS code.
The only hint I have is this error msg:
0x80070005 - JavaScript runtime error: Access is denied.
I see it when I run Debug from VS. It is thrown at line if (!IsNullOrUndefined(window.localStorage) && IsNullOrUndefined(window.localStorage.SPAnimationEnabled)) of core.debug.js file from SP core.
Can anyone help me? I don't even know how to google it :s
Oh, I should also mention that I did clean and rebuild all but nothing helped. Also there are no errors thrown - either on VS output or in event viewer.
The project was under svn, so I fixed it by checking out to other directory. And it works just fine. I guess it had sth to do with permissions.

Javascript not working on localhost, but it is working on Live site

I am facing JavaScript problems on XAMPP Localhost. The Collapse Buttons, go to top button and jQuery news feed are not working on every site on my localhost.
But Facebook, Twitter, Plusone buttons load correctly from remote server i.e. from the respective Social Sites.
So, I think it narrows me to the point that the JavaScript files hosted locally are not executed while those from Facebook etc. are getting executed.
I tried reinstalling XAMPP but didn't work.
I know this is old but, I had the same problem and found this question while searching a solution. But I have lampp installed on ubuntu and since Linux asks permission to execute ANYTHING, the local js files which resided in htdocs were without permission. After:
sudo chmod 777 -R /opt/lampp/htdocs
... everything was OK. Hope this helps future wanabee web developers.
It should not matter whether your files are local or not...javascript should still get executed. Try using some debugging tool like to see if you get any errors that only occur on your local machine. Because it could be that you are running some code that is depending on a domain or whatever.
I know this post is old and the answer is already given, I just wanted to give an answer of a possible reason that I encountered in case someone else finds this and it does not help.
Make sure your entire html code gets executed by viewing your page source. With me, half my code was not being executed due to a PHP error that was working on localhost with the local database but not on live with the live database. This caused the HTML to cut of from that point above my javascript.
So check your page source. If it is being cut of somewhere, find out why :)
I had the same problem. I try a lot but finally solved. The main problem was my browser cache that prevents from loading the new JavaScript file. My recommendation is that clear your browser cache data then close the browser and reopen your site again it will work perfectly.
remove any (pre in post ) blank spaces from filenames of your namespace example : localhost:port/dir /index.html
localhost:port/dir/index.html
In similar cases,
If web project site runs JS on Live Server but not on locally opened index.html,
try to check validity of HTML File Paths,
e.g you may have written:
<script src="script.js"></script>
instead of:
<script src="./script.js"></script>
Try to add ./ before file name.
./ means Current directory.

Categories

Resources