I have implemented a task in Hive.
But now I need to call a Shell Script which I have written for importing the tables in Hive from SQL Server using SQOOP. In that Shell Script I have written a SQOOP Command for importing the tables in HIve.
I tried to call a Shell Script in one of the Demo Application but as the Program runs no action taken place. I just see the blank console.
Do I need to do something extra in case of Hive?
Please help me out from this.
Thanks.
Try to run /bin/sh /home/....TableToExport.sh.
This explicitly defines the shell that interprets your script. This should work.
If it does not work try to simplify your command line. Start from running simple command like ls or hostname. When it works try to execute something more complicated.
Generally it should work. You are on the right way.
Related
I am trying to execute powershell commands from Java and have tried multiple options.
Commands that I want to try -
$SecureFilePassword = ConvertTo-SecureString -String "<PFXPassword>" -AsPlainText -Force
$userPFXObject = New-IntuneUserPfxCertificate -PathToPfxFile "<FullPathPFXToCert>" -PfxPassword $SecureFilePassword -UPN "<UserUPN>" -ProviderName "<ProviderName>" -KeyName "<KeyName>" -IntendedPurpose "<IntendedPurpose>"
I tried using ProcessBuilder to execute these - but i am not able to maintain session and hence it starts saying cmdlet not known even after importing the corresponding ps1 file.
Then I started with using jPowershell - here everything works fine except the above commands when it tries to use the set value inside $SecureFilePassword inside the next command - it fails saying "Not Specified"
Not sure if I am formulating the command properly to be executed - could some one help me?
Thanks
Sri
I would suggest to write a PowerShell script in a file that could be run in your shell as a single command and after that use ProcessBuilder.start() or Runtime.exec() method to run an external command from Java. See class Process API for details
I'm trying to code a shell script to start/stop torrents using vuze's console UI through SSH:
https://wiki.vuze.com/w/Console_UI
I've downloaded vuze and everything works fine until I type this command:
java -jar Azureus2.jar --ui=console
After that, no command in my script works unless I quit that console.
Any solutions please? And if it's not feasible using shell scripts, any suggestions please?
Thanks.
Basically, the moment you run that command, your java program runs 'in the foreground', which means the rest of your script stops executing until your program exits.
If you want to keep on running the rest of your script while your java program executes you have to run your program in the background. One way to do that is as #Alp suggests:
java -jar Azureus2.jar --ui=console &
The following process normally works for my startup scripts. However, when I introduce a command to execute a JAR file, it does not work. This script works while I am logged in. However, it does not work as a startup script.
In /etc/init.d I create a bash script (test.sh) with the following contents:
#!/bin/bash
pw=$(curl http://169.254.169.254/latest/meta-data/instance-id)
pwh=$(/usr/bin/java -jar PWH.jar $pw &)
echo $pwh > test.txt
Make script executable
In /etc/rc.local, I add the following line:
sh /etc/init.d/test.sh
Notes:
I make a reference to the script in /etc/rc.local, because this script needs to run last after all services have started.
Please do not ask me to change the process (i.e., create script in /etc/init.d/ and reference it from /etc/rc.local), because it works for my other startup scripts.
I have tried adding nohup in front of java command, and it still did not work.
Thanks
As written, there is insufficient information to say what is going wrong. There are too many possibilities to enumerate.
Try running those commands one at a time in an interactive shell. The java command is probably writing something to standard error, and that will give you some clues.
I want to make a reading entry for my java application to get some data from a bash script which runs regularly, so that my application can store the data in a database each time .
any ideas please ?
Let the bash script start your Java program and supply data through command line parameters.
Does the bash script print that info to stdout? Is it possible that you launch the bash script from the java application?
In that case you can do something like
Process p = new ProcessBuilder("bash-script").start();
And you can get stdout from the process with p.getInputStream();
I have a large number of source commands to execute. So I want to write some Java code to do this. Is there a way to do this in Java?
source command is like this:
mysql> source /home/liova/download/tpch/queries/Q1.sql;
You can execute any shell command using Runtime.exec:
Runtime.exec("mysql db_name < /home/liova/download/tpch/queries/Q1.sql");
You can use Runtime class to execute any commands in java. It executes the command as seperate process.