I need to run a shell command, that will call the script file that I have written in RUBY
For eg: Lets say, I have a file.sh in my working directory, How can I execute this file using TideSDK( I tried Using the Process)
Titanium Desktop createProcess to run shell script
Is there some other alternatives for this kind of stuffs in tideSDK?
Thanks
UPDATE:
I need to run the ruby script after a click of a button.
I think you don't need to run a process for that. TideSDK allows you to run other scripts like php, ruby and python directly in script tags. On the tag you just need to define the script on the type attribute: text/ruby
There ar several methods to include scripts on TideSDK. Take a look on the documentation at www.tidesdk.org. There is a section related to how to get started.
http://tidesdk.multipart.net/docs/user-dev/generated/#!/guide/using_ruby
Related
I have a python script that I need to execute and automate via IICS. The output of the script is a csv file. This output should be loaded to the Target. How can I achieve this via Informatica cloud. Please help with some info and documentations to the same.
Thanks
There are two ways to do this.
You can create an executable(using py2exe or some tool) from your py script. Then put that file in Informatica cloud agent server. Then you can call it using shell command. Please note, you do not need to install python or any packages.
You can also put the .py file in agent server and run it using shell like $PYTHON_HOME/python your_script.py You need to make sure py version is compatible and you have all packages installed in agent server.
You can refer to the below screenshot for how to setup shell command. Then you can run it as part of some workflow. Schedule it if needed.
https://i.stack.imgur.com/wnDOV.png
I am trying to start out using Notepad++ to run SQLite commands. I have tried following two brief YouTube tutorials to get me going. I can run the initial .bat file, but still cannot run the .sql file.
I have a Windows system environment Path variable set to the folder containing sqlite3.exe
"C:\Users\Adam\sqlite\"
I have saved the following file RunSQLite.bat in the folder containing sqlite3.exe
sqlite3.exe testDB.db
I have created a second file queries.sql
SELECT 34;
When I try to run queries.sql from Notepad++, using the RUN command:
C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)"
the only file that appears to run is RunSQLite.bat, giving the output:
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite>
Can anyone tell where I have gone wrong?
Thanks in advance.
aphopk
This C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)" will do exactly the same thing if run at the shell. RunSQLite.bat does not take any arguments so the Run command in npp is working as expected.
sqlite3 takes input from an external file with the .read command.
Path issues notwithstanding a bat file something like this should accomplish the task:
sqlite3.exe testDB.db ".read %1"
Notepad++ is a text editor, so you can now use it to edit your SQL file. After selecting the Language > SQL, Notepad++ will highlight SQL syntax as you type. Try typing some SQL, like
SELECT "Hi";
SELECT * FROM mydatabase WHERE id LIKE 'ID%';
You will see color, bold, and other possible formatting applied to the text you type. If you save the file as something.sql, and then load something.sql in your SQL client, the client will run the SQL commands from that file. If you have an existing somethingElse.sql file, you can open it in Notepad++, which will auto-recognize that it’s SQL and apply the syntax highlighting, allowing you to edit it and save it.
By using the Run > Run dialog, you can run an arbitrary command. For example, if your SQL client has a command-line mode accessed thru sqlclient.exe, you could type
c:\path\to\sqlclient.exe $(FILE_NAME)
If you just run it, that probably won’t show you any results… but if you ran
cmd /k c:\path\to\sqlclient.exe $(FILE_NAME)
It will open a new cmd.exe Windows command prompt, and show the output from that file.
If instead of running, you hit “SAVE”, you can give it a name (which will end up later in the Run menu), and/or a keyboard shortcut, so that you can easily re-use that many times.
If you want to do something more fancy, use the NppExec plugin, which includes a better batch/scripting language. Once again, you can save the NppExec script, and make it show up in the Macro menu.
If Python is a programming language you know or could learn (or if, like me, you know enough other programming languages that you can fake the Python), then the Python Script plugin will allow you to do even fancier stuff. (Python is a complete programming language, and has many libraries written, which could act as an interface between your SQL source file and your database engine; PythonScript has access to a full python2.7 interpreter. For example, you could write a script in Python which executes the commands from your SQL, grabs the results from your database engine, and displays them in Notepad++, either inline with your original SQL code, or in a new text document. You are really limited only by your imagination and knowledge of Python.)
How I can run MyDaemon.php in background in TideSDK app?
MyDaemon.php - it's my completely ready console software (a lot of code, run other my php scripts, run other software, etc). It's endless php script. It must be start after TideSDK APP and live all time before exit (while user don't close app). TideSDK show status from MyDaemon.php and have few buttons to control it.
Issue 1: How can I start MyDaemon.php in:
Ti.Process.createProcess("?path/to/php/from/tide? -f MyDaemon.php");
What write in "path/to/php/from/tide"? Target computer of my users don't have php package. I want run php from TideSDK like console mode. I include feature PHP and use button "Package with Runtime" in TideSDK Developer. I looked for all files inside TideSDK, but there are nothing like "php" (executing file), only libs.
Issue 2: I try to use
< iframe width=0 height=0 src="MyDaemon.php"></ iframe>
But TideSDK can't start UI APP, because can't take FULL source in frame. MyDaemon.php is undless. How can I include < IFRAME> in ASYNC mode like a real browser?
I try to use this trick:
<iframe width=0 height=0 src="" name="php">< /iframe>
<script>setTimeout("frames.php.location.href=MyDaemon.php", 1000)</ script>
But it's not work too (UI APP started, but halted after execute this frame).
MyDaemon.php can communicate with TideSDK APP any way:
start "/bin/php -f MyDaemon.php" and read/write stdin/stdout. MyDaemon.php can write to stdout any commands in JSON format.
start MyDaemon.php in and write to stdout < script>Ti...[commands]< /script> - any direct JS code for TideSDK
write any msg to file1 and read from file2 (TideSDK will read/write there and execute)
write any msg to SQLite DB (TideSDK will read DB on JS code)
Any other way.
It's important: MyDaemon.php want to start in console other php files! Because first process run a lot of childrens for calculating very long tasks. I can ask TideSDK for start this childrens and don't use "exec(/bin/php -f second.php)" in MyDaemon.php.
But I don't want to include double PHP binaries to my APP, because TideSDK APP already have it! It's a lot of extra space in dist.
Thank you and sorry for my language.
I think you should use Ti.Process.CreateProcess() function, where you can receive the output of the command you are using (I'm using JS syntax for this, not php, so I don't need to include extra libraries to execute commands, or write/read operations)
first you have a command cmd or shell command, lets say "ls -la /www"
then you need to send all the set of instruction as an array: var cmd = ["ls","-la","/www"]
then pass it to a var using Ti.Process.CreateProcess() : var echo = Ti.Process.CreateProcess(cmd);
to get the output, you could pipe out the content to another set of instructions.
the final program should look like this:
var cmd = ["ls","-la","/www"];
var echo = Ti.Process.CreateProcess(cmd);
echo.setOnReadLine(function(data) {
console.log(data);
});
echo.setOnExit(function(data){
console.log('process ended');
console.log(data)
});
echo.stdout.attach(echo.stdin);
echo.launch();
Instead console.log, you can pipe out the command output to your div.
also, besides main.html, you cannot load another scripts besides that. TideSDK is not a web based structured platform where you can reach a secondary page inside of the domain accessing it through url (like app://main.html is the only one to be loaded, have tried with no luck to call other "pages"), but instead modularize your app to load elements inside of the main page.
now, creating a daemon is a risk here. You need to be aware that depending on how you refresh the content it could increment severally the CPU usage.
I can suggest you to use a javascript loop to a shell command using the content above written. you do not need a real "daemon" or a secondary script since TideSDK can provide on certain extension that inside TideSDK
I have a scenario where I want to log every activity for a particular user. I have a script built around the script command which I invoke from the user's .profile. Now the requirement is that the user should not be able to delete the subsequent typescript file that is created. Towards that, I've created a user with the default shell of rksh and put a restriction on commands that can wipe the file out. But the problem is that when I login with that user, if I call the script with the script command, the forked shell is always sh and not rksh. I know that if SHELL is not set, then the forked shell will be /bin/sh by default, but I have SHELL setup properly. How do I ensure that the forked shell is rksh only?
If I comment out the call to the logger from .profile, then I get a rksh shell. But even then if I manually issue the script command, it launches sh. Any help will be appreciated.
Thank you,
I have a main script in a folder called main.ksh (in /home/pkawar/folder), and its input input file inputfile.xls (in /home/pkawar/folder/ipfile).
When I run main.ksh, it uses inputfile.xls and deliver the output to a mail address.
The inputfile.xls is loaded to path /home/pkawar/folder/ipfile via ftp commands.
Is it possible to run main.ksh automatically and output will be sent via mail when the file inputfile.xls is loaded successfully?
The first option would be to use cron, but from your question it doesn't seem that you want to go that path.
My question would be, what is creating the *.xml file? Is it possible that whatever is creating that file to know when its finished and then calling the shell script, or better yet, have the xml file streamed to the shell script on the fly?
The first thing you should do is write a script that does whatever it is you want done. If your script performs correctly, you can use cron via a crontab file to have the script executed on whatever schedule you desire.
See man crontab for details.