"nohup ./filename.sh" not working in tSSH talend component - talend

I'm using the tssh component to unzip a file, then delete the zip folder on a host which works fine.
The problem is when I try to run a .sh file in the same directory. In the commands for the tSSh component I have added the command
nohup filename.sh > outfile.out
in which case I get the error
no such file or directory
I have also tried
nohup ./filename.sh > outfile.out
but now the error is
./filename.sh command not found
All I need to do is execute the sh file.

Is your home directory the place where you expect to find the script filename.sh?
If yes, maybe you have a "cd" in your startup file.
If not, try to give 2 commands for nohup:
nohup `$(cd yourDirectoryPath ; ./filename.sh > outfile.out)
If you can't retrieve the result in outfile.out, check for nohup.out (and remove the redirection from the command line).
Hope this helps.
TRF

Related

Bun Not Found After Running Installation Script

I have ran the installation script by pasting this code:
$ curl https://bun.sh/install | bash
However, when I try to get the version of bun, it says it could not find it:
$ bun --version
Command 'bun' not found, did you mean:
command 'ben' from deb ben (0.9.0ubuntu2)
command 'bus' from deb atm-tools (1:2.5.1-4)
command 'zun' from deb python3-zunclient (4.0.0-0ubuntu1)
Try: sudo apt install <deb name>
I had the same issue running on Windows 10 WSL2 Ubuntu-22.04 with Bun v0.1.5.
The solution (and more detail just in case anyone needs it) below:
The executable for bun is in the directory "/home/username/.bun". You need to add this to your $PATH so that this can be found when typing bun commands such as "bun --help".
The bun setup process does not add this path so you need to do it yourself.
Two ways to do this :
(1) Manual method
Type in the terminal:
export BUN_INSTALL="/home/YOUR_USERNAME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
Note: This process will have to be REPEATED for every new shell you open.
(2) Automatic method
Edit the .bashrc file :
nano ~/.bashrc
at the end of this file add
BUN_INSTALL="/home/YOUR_USERNAME/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
(Remember to save your changes with Ctrl-O)
Note: You will NEED TO OPEN A NEW SHELL for this to work OR type 'source ~/.bashrc' to use in the current terminal.
You should now be able to run bun commands in any new shell.
The installation script says a message at the end telling you how to add bun to your PATH manually. Here is that output:
Manually add the directory to your $HOME/.bashrc (or similar)
BUN_INSTALL="/home/sno2/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
I advise you re-run the installation command and copy the environment variables and add them to your PATH.
export BUN_INSTALL="/Users/manendra/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
add these to your .bashrc, .zshrc or you can use export command to use for current session.
Note: Change your username place of (manendra) "/Users/manendra/.bun"
Manually add the directory to ~/.bashrc (or similar):
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
From the installer, last message is:
To get started, run
exec /bin/zsh
bun --help

When can I use the command 'mongod' in Command Line?

I recently installed the version 4.4 of MongoDB,I followed all the instructions as in the documentation of mongodb.
As instructed by my tutor I created another folder named 'mongodb'in my pc,inside which I created another folder named 'data' as well.Now i went to the command prompt and entered into the same mongodb folder i created earlier and typed the following command.
C:\Users\Dell\mongodb>mongod --dbpath=data --bind_ip 127.0.0.1
When I press Enter I see an error :
'mongod' is not recognized as an internal or external command,operable program or batch file.
I am totally stuck in this.I even reinstalled mongodb again,but it is not working.
You might have a problem with path in Mongodb. After the installation process ends open a
Command Interpreter with Administrative privileges and run:
"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe"
Now afterward you can use the 'mongod' Command. If still you are unable go to the pre insatlled Mongodb folder copy the path upto bin .
Now go to :
controlpanel>system and security>system>Advanced system settings.
A dialogue box appears and then at the bottom there is the option for Environment Variables.Click on that.
If Mongodb variable already exit delete that and click on the path option. You might see a new option somewhere around click on that and input box appears.Now paste the copied path in that box and click save/Ok or sth to end the options.
Now you can use the 'mongod' command .

How to load scripts in MongoDB

I'm using MongoDB version 3.0 and I want to run script.js on database
Problem I have find is that mongo is not seeing my file script.js.
What I have done step by step:
I have installed MongoDB in directory MongoDB\Server\3.0\bin\
I have put script.js inside \bin directory
I want to do is run script.js using load() method
I have got an error
load("script.js")
2016-10-09T22:17:17.557+0200 E - file [script.js] doesn't exist
2016-10-09T22:17:17.558+0200 E QUERY Error: error loading js file: script.js
at (shell):1:1
Probably I have put script.js in wrong place but where I should put it?
Next step is I'm using mlab and I want to load my script to the online server, how to do this?
I don't know of any magic that would make a \bin directory relevant, but assuming that your script is located in /bin, you just need to call out the full path when you do the load from within the mongoshell
load('/bin/script.js');
If your script is located off your home directory it will be like
load('/Users/yourname/script.js');
See the docs for load: https://docs.mongodb.com/manual/reference/method/load/
Ditto for how you run it on "the server". Its not so much running on the server, but in the shell that you are running. If the shell is connected to a particular server, the effects of the script will be on the server but the script itself executes in your shell.
For windows try:
load('c:\MongoDB\Server\3.0\bin\prova.js')
load("C:\\Data\\Mongo\\M001\\loadMovieDetailsDataset\\loadMovieDetailsDataset.js")
Double \ does the trick. I was receiving similar error as my install path was not set and the file res
Try changing the name of the .js file. In my case, the error was coming because the folder name and the file name were the same.

how to run a cmd file from matlab

I am trying to run a cmd file from MATLAB but unable to execute it. Can anybody see nay problem in the below code?
this is what I have inside my cmd file:
echo on
>test.log 2>&1 (
C:/testProj/Make/makeit.cmd param1
)
And this is the MATLAB code:
Out = 'C:/testProj/test.cmd';
system(Out);
But this actually does not run the cmd file.
Well for somereason it would not run if i would give the complete path of the cmd in bat file. so I had a cd command to change the directory and then run. now it runs fine, Thanks all appreciate your help!
What about using eval, like this:
eval(['!test.cmd']);
I have succesfully used this to run .bat files (and this output of the .bat script showed in my matlab command line). I also found this dos command, but I am not sure if it works allright:
You can just type the following strings to get things down:
!(c:/testProj/test.cmd)
This is actually no different from
system('c:/testProj/test.cmd')
I think you should check if the path is wrong. As to your code in the cmd file, that's beyond my ability to help.

Running Executable from Shell Script

I am having trouble launching an executable that I have created from a shell script. I would like to automate testing by running the program many times with different command line options to verify it is working.
When I type echo $SHELL, /bin/sh is displayed.
The following is my shell script:
#!/bin/sh
clear
echo "Running first test."
./myProgram
exit 0
When I run the script (sh myScript.sh), with myProgram in the same directory, I see the following output:
Running first test.
: not foundsh: line 4:
When executing the program ./myProgram, it runs as expected with no command line options.
I have also tried:
myProgram
./myProgram &
myProgram &
based on answers to somewhat similar questions, but they all result in the above error message.
Your newlines are goofed. Use dos2unix to fix.
why don't you try using the full path?
e.g., if myProgram is in /home/user1/bin, you can try /home/user1/bin/myProgram instead of ./myProgram. This should work.
You can also add the path to path variable, $PATH and directly call myProgram from anywhere.
Run "export PATH=$PATH:/home/user1/bin" on your terminal without the quotes. Note that this affects only your current termial session. If you want to permanently add the path, update your .bashrc file in your home directory with the following line: