Erlang Output to text file - windows

I am new to Erlang and I am trying to find an easy way to output Erlang command results to a test file in Windows command line. This is what I tried so far:
c:\Windows\Temp>erl example.erl "main" -e > output.txt

if its a small script perhaps you can use escript as described in here
escript provides support for running short Erlang programs without
having to compile them first and an easy way to retrieve the command
line arguments
then you can get what you want to work the way you want
escript myfunctions_tests > output.txt

Related

Is it possible to make a .bat Bash hybrid?

In cmd, it is possible to use Linux commands with the ubuntu or bash commands, but they are very fickle. In batch, it is also possible to make a VBScript-batch hybrid, which got me thinking, is it possible to make a Bash-batch hybrid? Besides being a tongue-twister, I feel that Bash-batch scripts may be really useful.
What I have tried so far
So far I tried using the empty bash and ubuntu commands alone since they switch the normal command-prompt to the Ubuntu/Bash shell, but even if you put commands after the ubuntu/bash they wouldn't show or do anything.
After I tried that, I tried using the ubuntu -run command, but like I said earlier, it’s really fickle and inconsistent on what things work and what things don't. It is less inconsistent when you pipe things into it, but it still usually doesn't work.
I looked here since it seemed like it would answer my question and I tried it, but it didn't work since it required another program (I think).
I also looked to this and I guess it failed miserably, but interesting concept.
What I've gotten from all of my research is that most people think when this is mentioned of a file that could be run either as a .bat file or as .sh shell file instead of my goal, to make a file that runs both batch and Bash commands in the same instance.
What I want this for relates to my other question where I am trying to hash a string instead of a file in cmd, and you could do it with a Bash command, but I would still like to keep the file as a batch file.
Sure you can use Bash in batch, assuming it is available. Just use the command bash -c 'cmd', where cmd is the command that you want to run in Bash.
The following batch line pipes the Hello to cat -A command that prints it including the invisible symbols:
echo Hello | bash -c "cat -A"
Compare the output with the result of the version completely written in Bash:
bash -c "echo Hello | cat -A"
They will slightly differ!

Perl: Why do I get error "The file name, directory name, or volume label syntax is incorrect."

I am trying to run the below perl code from Windows batch file but getting error The file name, directory name, or volume label syntax is incorrect.
The script ran fine in eclipse.My ultimate goal is to run this perl script periodically using windows task scheduler, hence running it from a batch file.
Is there any other ways with which we can achieve my goal of running perl script on windows periodically?
I want my script to be functional across platforms, coz I have plans to run it from a mac as well.
use strict;
use warnings;
use Data::Dumper;
use File::Find::Rule;
my $basedir="G:\/My_Workspaces";
my #exclude_dirs= qw(.foo);
#Fetching all the workspaces under base dir excluding the ones in #exclude_dirs
my #subdirs =
File::Find::Rule
->mindepth(1)
->maxdepth(1)
->not_name(#exclude_dirs)
->directory
->in($basedir);
#Formating list of workspaces by removing the full path
s{^\Q$basedir\E/}{} for #subdirs;
If that is exactly the contents of your file, then you're asking Windows' command interpreter to process Perl source code, which it can't do
If you really need to create a batch file that has your Perl code embedded in it, then take a look at the pl2bat utility, which will do exactly that
A command like
pl2bat myperl.pl
will create a file myperl.bat that will run on the Windows command line and has your Perl source code embedded inside it. But that file is non-portable because it uses Windows commands that aren't recognised on a Mac or Linux platform
Either something doesn't know how to execute your Perl script, or your Perl script is being interpreted by something other than perl.
This could due to a problem with your file associations (or a lack thereof). Determining the exact cause would require more information.
In any case, executing perl with your script as a parameter rather than executing the script directly should solve the problem.
In other words, execute
perl script.pl
instead of
script.pl

Ruby: How to open .exe file(that open CMD) and run command init

I am trying using ruby script to a task.
I have an .exe file that i want to run.
when opening this file it open in CMD and i can pass commands to it.
That file located in C:\temp\test.exe
I need to go to the directory and then open the file and then insert to it command like:
"getobject" task = "aa"
this program will give me the result to the CMD.
i will need to copy the result to text but i think i can handle it late.
I tried to search it online cant found anything.
Thanks
If you want to open an executable, usually you can use the `command` syntax in Ruby. So call:
`C:\temp\test.exe`
That should run the executable from the Ruby script. Then you can interact with that executable as if you ran it from a CMD instead of a Ruby file.
In order to run and capture the output of a command you'll need to use a system command. There are many system commands that you can use, but my preference is Open3:
require 'open3'
output, status = Open3.capture2("C:\temp\test.exe")
In the event that you want to pass command line arguments to capture2 you'll want to write that like this: Open3.capture2("C:\temp\test.exe", "arg1", "arg2"). That is the safest way to pass arguments.
I think what you are looking for is input/ output redirection
check redirection
Not tested
system 'C:\temp\test.exe < "\"getobject\" task = \"aa\""'

GVIM: How to pass in multiple arguments via a file under windows

Is anyone aware of a command line option or a way to pass in a file to gvim which will use the contents of that file as a list of arguments?
Achieving this without having to populate argv with a list of files.
The problem is that vim is a unix tool which by default assumes that a list of files would be piped in, if there are say 1000 files that need to be opened, however in the windows world there is a limit to how many arguments you can have on the command line. The way to do this on a windows command line is to have a file which contains all the arguments you wish to pass onto the program. I am wondering if gvim provides such an option.
Note: This is to invoke gvim in a windows compatible way i.e. avoid using extremely long argument lists
A simple solution:
list your files in files,
file1
file2
file3
open Vim with the command below,
$ vim -c next `cat files`

Run external command from within Perl

I am using Doxygen to generate HTML documentation and then run a Perl script to get function names.
To run Doxygen configuration, I need to run doxygen file_name in cmd.
But I want to run everything from Perl.
I tried this code
my $cmd = "perl -w otherscript.pl";
my $result = system("start $cmd");
But it just opens a cmd window. I need to execute cmd code directly through Perl (not a Perl command line, but through a Perl IDE). Is there a way to achieve this?
Your usage of system and start is OK.
From your description in the comment, I think it's because you're not using the correct escaping method when giving configure files to Doxygen that it throws such an error:
Error: configuration file C:SERSGHOSHBCD not found!
Try with
my $result = `doxygen C:\\Users\\aghosh\\abcd`;
In the two back-slashes, the former one is to escape the latter one, so that it's recognized by Windows as the directory separator.

Resources