Display message to terminal with freewrap for tcltk? - tcl

I am using freewrap to package a program into a single file. It seems freewrap has two options freewrap and freewrapTCLSH. Since freewrapTCLSH was created for a command line tool in mind it displays any puts "some text" to the terminal. However, with freewrap any puts "some text" does not show on the terminal.
The program is GUI based so I cannot use freewrapTCLSH. However, it uses procedures that displays info to the terminal. While there might be a better way to show info for a GUI based program, these procedures are third party so I cannot change the fact that info is trying to be sent to the terminal.
Is there a way for a freewrap program to display info to the terminal?

Related

View SQL code for job in SQL Server Management Studio

I want to view the SQL code that is executed for a particular job in SQL Server Management Studio.
Specifically, I have a screen that looks like this:
If I double click it I get a screen that looks like this:
That is not really helpful. I want to see the actual code that is running and possibly modify it.
I am a long time developer but new to Windows so please give an answer that uses terminology that I can see on the screen.
[EDIT] If I click the edit button on the first screen I get the same screen as if I double click it. There is a DTSRun command and some jibberish which is not anything I would expect to edit.
[EDIT] I followed these instructions to decode the encrypted command line:
https://blogs.technet.microsoft.com/vipulshah/2007/03/12/how-to-identify-which-dts-package-is-being-called-by-scheduled-job/
Then I could see the command line looks like this:
DTSRun /S "192.168.2.1" /U "sa" /P "changeme" /N "Delete AppErrors"
I then searched the entire computer for a filename that contained AppErrors in the name. I did not find one.
So I am getting closer, but how do I find what that is executing?
There is no SQL code in this job/task, because the task type is "Operating system (CmdExec)", i.e. this is not a SQL query, but starting of Windows executable file. There will be SQL code for step type "Transact-SQL script (T-SQL)":
What you see in you job step, is execution of SSIS package, which is encrypted. For more information about DTSRun command, take a look at this article - SQL Server DTS command line utility.
I almost solved my problem like this:
A.
I followed the instructions here to decode the encrypted command line:
https://blogs.technet.microsoft.com/vipulshah/2007/03/12/how-to-identify-which-dts-package-is-being-called-by-scheduled-job/
Which amounted to:
Copy the DTSRUN line (everything including the DTSRUN)
Open a Windows Command Line window
Paste the DTSRUN line into the CMD window.
To the end of the line, add /!X /!C
/!X = do not execute /!C = copy results onto Windows Clipboard
Run the command
Open Notepad
Click Edit>Paste
that will paste the actual command into Notepad and it will show the name of the package.
B.
I observed that the command line looked like this:
DTSRun /S "192.168.2.1" /U "sa" /P "changeme" /N "Delete AppErrors"
C.
Then I follow the instructions here to find the code:
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/cc645945(v=sql.105)
which amounted to:
In Object Explorer, expand the Management folder.
Expand the Legacy subfolder.
Expand the Data Transformation Services subfolder to show packages.
D.
I right click on it and choose Open. I get this error:
I should not have to install anything because the person who put this on the machine must have been able to edit it. (this person is completely unavailable so I can't ask him). The reason I need access to it is that we are upgrading the machine.

Command to send signals to waveform in SimVision

Is there a (Tcl-)command I can use to send signals to waveform in SimVision?
Of course You can rightclick them and then select "Send to WaveForm Window", but to do that each time you start a simulation will be a pain.
In Modelsim you can easily use "add wave" in a dofile (tcl file), but strange if there would be no way to do this with ncsim...
When you have your waveform window set up the way you like (with all desired signals), you can go to File -> Save Command Script . This will save your window setup as a tcl file. You can look in there to see what the tcl commands are if you are interested in doing it manually.
To restore the waveform window next time, simply go to File -> Source Command Script and select the file you had saved previously.
Note: I'm using SimVision 12.10
a minimal working example I've come up with:
window new WaveWindow -name "Waveform"
waveform using {Waveform}
waveform add -signals tb_foo_u.module_bar_u.signal_xyz
You can type that in the SimVision console (if you're using irun in GUI mode). Tested in 15.20. Those are simulator-specific commands.
If you want it to be done automatically # irun startup (using .tcl file), examine the results of running commands from the other answer, then tailor it to your needs.
For the full, verbose description of waveform instruction, refer to the documentation provided with the simulator under SimVision Tcl Commands / waveform.

Open a Tcl file with Wish Application

I'm running Windows 8. I have a file named "test.tcl".
If I open a shell, type "wish", then 2 windows open. In one of them, I can type Tcl code and open the file test.tcl. If I open this file, its code is executed.
If I double click on test.tcl to open the file with "Wish Application", then 1 blank window open, and nothing happens.
Do you know why please?
On Windows, Wish is built as a GUI-only application; it has no real standard output available. Tk fakes one for you though; just put this in your script to show the fake console:
console show
The fake console shows up by default when you launch without a script file, but launching with a script file doesn't show it (so your script file can implement an application, of course).
This can catch people out when they produce a lot of output on stdout. Tk may well be keeping it all faithfully just in case the code does console show later on, though it looks and smells a lot like a memory leak if you're not prepared for it…

start opened file from sublimetext in associated program

i usually edit files in sublime text 2 that can also be edited and compiled with another program. As i have them already opened in sublimetext i do the following:
right click and choose "copy file path" (to clipboard)
Win+R to open windows run dialog
CTRL+V to paste the file path
hit enter to open the file with the associated program
i wonder some shortcut can be configured so it automatically starts the opened file with its associate program
thanks in advance
This can be done. I was in a very similar situation using Sublime as my editor of choice over the default SAS program editor. I was able to use the win32com.client.dynamic.Dispatch module to connect to SAS via OLE and pass text from Sublime directly to SAS using Sublime's build system to call my plugin. Making the connection was the easy part, it was the other processing that I had to do which was the time consuming part, but since you want to pass just a file name or the entire contents of your file, this should be a fairly straightforward plugin. Since I do not know what program you wish to open, here is the code that makes my implementation work. Maybe you caan glean something out of this.
def send_to_sas_via_ole(selected_code):
from win32com.client.dynamic import Dispatch
sasinstance = Dispatch("SAS.Application")
# submit the lines to sas
for selection in selected_code:
# for some reason cannot send as one big line to SAS, so split into
# multipe lines and send line by line
for line in selection.splitlines():
sasinstance.Submit(line)
and then the call in the run method of my plugin class:
class RunSasMakoCommand(sublime_plugin.TextCommand):
def run(self, edit):
try:
send_to_sas_via_ole(selected_code)
except Exception as e:
print "\n".join(selected_code)
print "Couldn't connect to SAS OLE"
print e
Good luck!
Open 'regedit.exe';
Navigate to
HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
correct the path. Exit 'regedit.exe'
(optional) restart 'explorer.exe' or reboot your PC.
enjoy :p;
Right click on the file, press "Properties". You will see Opens with SomeProgram and then a change button. Click on the change button, and then look through the list for Sublime Text, if you can't find it, you can choose an application using the file explorer, from there you can navigate to C:\Program Files\Sublime Text 2 and choose sublime_text.exe

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.