I have a client/ server program written i c language, a client can send and receive .txt documents to the server, i wish to Open the file received to visualize it with command nano For example, inside the running process:
Something like this:
Exec( nano, "file-to-Open.txt") but i dont know how to do do this), can You help me?
Sorry For my english
Thank's a lot
Try this:
execlp("nano", "nano", "file.txt", NULL);
The nano editor must be in your path, the file.txt must be in the current directory of the running client process, and most importantly, whatever display the editor is going to display on must be accessible, be it the terminal from where the client is run or the appropriate X-Windows display.
Related
I have a application written in C and i want to control writing of syslogs in txt file from application. On application there is option for START/STOP running, so basically when i press START i want to start writing syslog(journalctl) to /some_folder/debug.txt, and when i press STOP i want to close the file.
This can be done by linux command "journalctl [parameter] > /some_folder/debug.txt", but that is not enough, this must be controlled from application.
Does anyone have idea how this can be done properly, is there some API to control syslogs or i have to do it via system()?
If there is no way, if i have to use system() and journalctl commands are there some suggestion which commands to use?
I am currently on a machine where i have to change an existing script.
Nobody knows what path are.
I only know that modifies a file at startup , and it expects to have internet to do.
I try to find it with lsof but it looks like it is not enough "fast". It shows me nothing. I try to do with wireshark if he would send something, but nothing too.
I try to search with grep but nothing conclusive.
The machine is under OpenSuse x64 and i can be root.
Anyone have a solution for me? Thank you in advance.
Rc files or profile files are used to run commands on startup(depending on login or non login shells). These could be Generally in /etc - global and in home directory for user specific setting.
Have your considered checking contents of /etc/bashrc or /etc/bash.bashrc or profile? What did you grep for?
Hello guys im trying to make an extension that open any exe on user computer by simply textbox.user will write the path of exe he wants to open and i need to take that path to batch file and run it is that possible if that so how?
my current batch file only open one path but i want it to take paths from user and open that exe on path location
Well, Native Messaging does not allow you to pass command line parameters. It will only allow communication using the Native Messaging protocol (length + JSON-enconded message).
So you need to make a single native host that is able to read an incoming message, decode it and execute the command you want, i.e.:
// Extension side
chrome.runtime.sendNativeMessage('native.app.id.here', { command: "calc.exe" });
and then the app will receive, through STDIN, the length of the message + {"command":"calc.exe"}
Actually writing code that will decode that message using batch scripting is a terrible idea, but doable in principe. You should probably write an actual program in a language with support for JSON manipulation to handle this. See also this question.
I'm trying to download some files using a batch file, however after reading the username line an error is thrown 'Invalid command'.
In my batch file I call my ftp file as follows:
ftp -n -s:ftp_download.txt
my ftp_download.txt looks like this:
open myname.com
test#myname.com
test
lcd C:\myDownloads
cd download_files
get MY_NEW_FILES_*.xml
bye
However after the test#myname.com line an error is thrown 'Invalid command' and thus the script does not connect to my ftp server.
When authenticating as follows:
open myname.com
user test#myname.com test
I get the 'not connected' error
However using this username (test#myname.com) and password (test) I'm still able to connect using Filezilla .
Am I missing a command somewhere?
To those, like CharlesKSQL, who might stumble upon my question.
Here's how I got it to work (it turned out I had to use sftp for some reason so make sure it's enabled on your server);
The script (ftp_download.txt) contains the following:
option batch abort
option confirm off
open sftp://<username>:<password>#<host> -hostkey="<fingerprint/key>"
option transfer binary
cd <your folder>
get <some file>
If you do not know the fingerprint and/or key; you can find these in FileZilla when connecting trough sftp. They are shown in the popup that show up when you connect to your server for the first time or you could click the little lock-icon in the statusbar on the bottom right when you are connected already.
Now to actually connect you'll need a little bit of software (when using Windows) to create the secure connection. I used WinSCP.
You can download the portable executables here and place them (for easy usage) in the same folder as your batch file.
Then you can call the executable in your batch file by adding a parameter:
winscp.exe /script=ftp_download.txt
which should then execute your download script.
P.S.: it's been a while since I finished this, it's still working as far as I know.
Your text file should look like this:
open myname.com
user
<enter username here> <password here>
lcd C:\myDownloads
cd download_files
get MY_NEW_FILES_*.xml
bye
Try that and see if it helps
I want to add a custom line to windows kernel log, from a batch file, or from cmd prompt.
In linux, I would do this by writing to /dev/kmsg file. Anything written to that file would be visible via dmesg or /var/log/messages.
e.g. echo Hello world > /dev/kmsg
I want something very similar for windows side.
I am also OK if there is a solution like log_to_kernel.exe "my message", instead of redirecting to a device file. I think, there isn't concept of device "files" in windows.
The reason for requirement:
I am trying to debug some issues in a driver & for that I am running some test program, which internally makes calls to the driver in windows.
If the driver fails, I will be able to see the debug messages in the kernel windbg attached over 1394. The kernel debugger will hit a breakpoint/assert & I will not be able to check the iteration number on my target system, till I continue from windbg.
Hence I need to log the time & the test iteration number in kernel log itself, which I am planning to do via the batch file, which runs the automated tests.
Hence, I need some tool or dummy echo driver with C code, which would log my custom message in the kernel log.
In one line, I want to write a custom message to kernel log, from a user space app.
You are supposed to use DbgPrintEx function to write log entries if you are writing a driver,
http://msdn.microsoft.com/en-us/library/windows/hardware/ff543634(v=vs.85).aspx
Then the debugger should be able to display it.
If your application is user mode, OutputDebugString is the simplest,
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx
You might also read about event tracing,
http://msdn.microsoft.com/en-us/library/windows/desktop/bb968803(v=vs.85).aspx