Passing execution time parameters to TCL scripts from non interactive shell - tcl

I am able to run the TCL scripts on the linux server from the Non-interactive shell created by JSch library used in the java program from windows environment. The problem is I have some scripts which needs to pass certain parameters during the execution of the script based on the intermediate output of the script and after the parameters are entered, the script execution continues from there onwards. But as it is non interactive shell, I am not able to pass this parameters during execution. Is there any way where I can make it work ? I thought of an option where, I will pass the parameters as command line argument, but wanted to know any other way.

When you say "parameters", do you mean anything that a user would have entered in an interactive session as an input to prompts presented by the script?
If yes, there are two possibilities:
If the script does not expect the session to be interactive, and just reads its input from its standard input stream (using gets for instance), then just feed this input to the standard input of the tclsh process which interprets your script.
If the script does expect the session to be interactive (and refuses to just accept the data from its input stream), you will have to allocate a pseudo-TTY for the target process.
I'm not familiar with JSch, but this appears to be a question (and an answer) dealing with the making JSch allocate a PTY.

Related

Executing one subroutine without opening Access

I would like to know if there is an easy workaround for my following question. I have an access database that have different modules in vba (and of course each module with different subroutines). How can I do to create an icon or an executable file that by clicking on it it runs one of the subroutines of one of the modules without opening access?
The reason of this is because when I am away people need to run some of these subroutines and these users don't have any experience with Access.
You can start Access with a command line option to run a named Access macro. (That means an Access macro object. Some people also call VBA procedures macros, but an Access macro object is different.)
An Access macro has a RunCode method which you can use to run a VBA function. Since the code you want to run is a subroutine, create a new function which calls that subroutine and shuts down Access afterward, and use the function with the macro's RunCode method.
After you have the macro working correctly, test it from a Windows Command Prompt session following this pattern:
"<path to MSACCESS.EXE>" "<path to db file>" -X <macro name>
After working out those details, you can create a desktop shortcut to do the same thing.
However, if your Access operation must be run by you or another user on a regularly scheduled basis (daily, weekdays only, etc.), you could create a Windows Scheduled Task to do it and forget about other users and desktop shortcuts.
Note this suggestion isn't exactly what you requested because it does open Access. But it could close Access after the operation is finished, so perhaps it will be acceptable.

How to disable a modified tclsh interpreter interactive mode?

Run tclsh command without any tcl file, the interpreter will go into interactive mode.
Can I simply disable this feature by modifying the tclsh source code ?
I can't imagine why you would want to bother doing this, given that supplying any script file will turn off interactive mode. The script you supply will have full access to the additional arguments passed in (a list in the global argv variable) and the standard IO channels (stdin, stdout and stderr). It can exit when it is done. Literally anything you want can be done at that point; you've just got to write a script to do it.
If you're including Tcl in your own program, the behaviour of tclsh is implemented in the C function Tcl_Main. If you never call that — instead just using Tcl_FindExecutable, Tcl_CreateInterp and Tcl_Eval/Tcl_EvalFile — then you never get any of that interactive behaviour. While theoretically you could modify the Tcl source itself to do what you want — it's all open source — why would you bother when you could just not call that code in the first place?

Spawn xterm and issue commands using Expect

I'm trying to write a GUI using Tcl/tk where the user will select different parameters and hit a 'Submit' button. When the button is pressed, the program will open an xterm window and telnet and perform configurations based on the choices made by the user. I know this should be pretty basic but I've looked everywhere and cannot find a working method. Please advise. Thanks.
I think xterm isn't needed: Expect is able to provide a program (telnet in your case) with a pseudoterminal -- one of the things xterm does for the program it's running. So just google for this combo.
I don't believe that expect can control an X app such as xterm. It can however control a text app like telnet.
You can write a shell script that launches xterm, passing the "-e" option to execute an expect script. That expect script can then launch telnet.

How to get a response from a script back to Hudson and to fail/success emails?

I'm starting a Python script from a Hudson job. The script is started though 'Execute Windows batch command' in build section as 'python my_script.py'
Now I'd need to get some data created by the script back to Hudson and add it to the fail/success emails. My current approach is that the Python script writes data to stderr which is read to a temp file by the batch and then taken into an environment variable. I can see the environment variable correctly right after the script execution (using set command), but in the post-build actions it's not visible any more. The email sending is probably done in different process, so the variables are not visible anymore. I'm accessing the env vars in the email as ${ENV, varname} (or actually in debug mode as $ENV to print them all)
Is there a way to make the environment variable global inside Hudson?
Or can someone provide a better solution for getting data back from Python script to Hudson.
All the related parts (Hudson, batch and Python script) are under my control and can be modified as needed.
Thanks.
Every build step get's is own shell. This implies, that your environment variables are only valid within the build step.
You can just write the data in a nice format to the std output (use a header that is easy to identify) and if the job fails, the data output gets attached in the email.
If you insist on only putting in the data, you can use the following token for the Editable Email Notification post build action (Email-ext plugin).
${BUILD_LOG_REGEX, regex, linesBefore, linesAfter, maxMatches, showTruncatedLines, substText}

sending command and obtaining a reply from actionscript 3 / air

I am attempting to send a command to the command line with an air/as3 application.
I have seen some documentation on the invoke command but i am wondering if anyone else has dealt with the same set of circumstances.
basically the user will be checking boxes and filling out a form which will then be written as arguments to an application that will be doing the work. this application accepts these arguments as well as a place to store the output file and processes the file.
so is it possible to send commands to the command line using as3/air and furthermore is it possible to obtain the resulting message from the command line.
I have searched a bit for this sort of information but it seems that google returns a lot of 'how to compile as3 from the command line' tutorials and there are very few articles concerning air/as3 and it's possible interactions with the system's command line.
Thank you in advance,
-Nathan
there is no way to launch apps from AIR (explanation here), nor to send anything to the command line ... however mike chambers created CommandProxy that allows you to do so, interfacing with a C# counterpart ...
greetz
back2dos
AIR 2.0 has Native Process API. Through which now its possible.