Writing Bash shell scripts corresponding to windows bat files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing Bash shell scripts corresponding to windows bat files
# 15  
Old 09-18-2010
UNIX provides the special variable HOME which is almost certainly set to your users' home directory already. RIAMP_HOME seems redundant.

The path RIAMP_HOME/bin/... doesn't expand to what you want it to because you didn't put braces around RIAMP_HOME. Try ${RIAMP_HOME}.

Your first test is to test if the home variable is blank, and execute code inside the if statement when true. Your next test is the same -- only execute code in this block if the string is blank. So, it's backwards -- it will never be executed when the string is set. It's also completely redundant, since you tested for that 3 lines ago. You can leave out that "if" completely. (For the record, to check if a string is not blank, you do if [ ! -z "${STRING}" ]

Shell script doesn't have "call". It has . or source instead (they are synonyms).

"call" is not a subroutine and never has been, though if you treat it carefully and squint a little it's kind of similar. UNIX shells, more modern ones anyway, have actual subroutines:
Code:
function do_something
{
        echo $1
}

do_something "qwertyuiop"

And lastly, you'd still be much better off rewriting from scratch than "translating" a batch file. Tons of things that could only be accomplished in CMD via diabolical tricks are easy one-liners in a real shell -- your big library of batch routines may be mostly redundant now. Just naively translating them like this won't teach you as much about real shell scripting, and will probably encourage some bad shell-programming habits.

Last edited by Corona688; 09-18-2010 at 04:23 PM..
This User Gave Thanks to Corona688 For This Post:
# 16  
Old 09-20-2010
@Corona688

Thank you very much Corona688. I really appreciate. I am working on some java development stuff as well. This would be time consuming if I write from scratch now. That is why i am writing corresponding code for the same. I would definitely try to write shell scripts though.

Best regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing Hbase and pig scripts in the bash script file

Hi, I have a script file where i'm validatig the input file and storing the validated records on HDFS. I wanted to load data from HDFS to HBASE using pig script. So for that i have created a HBASE table and written pig script to load data from HDFS to HBASE which is working fine. Now i wanted... (0 Replies)
Discussion started by: shree11
0 Replies

2. Shell Programming and Scripting

Writing hive scripts in bash script file

Hi, I wanted to load data from HDFS to HIVE by writing bash script. Description: I have written a bash script to validate the data and loaded validated data from local file system to HDFS. Now in the same bash script i wanted to load the data from HDFS to HIVE. How can i do it ? Also how tyhe... (2 Replies)
Discussion started by: shree11
2 Replies

3. Shell Programming and Scripting

Create Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (1 Reply)
Discussion started by: rajuchacha007
1 Replies

4. Shell Programming and Scripting

writing shell scripts of commands

can anyone help me in writing a shell script to visualize how simple commands work and on what logic. For Eg: ls command how it lists out all the files and directories, need to write a simple script based on the commands source code.:D (0 Replies)
Discussion started by: rahul_11d
0 Replies

5. UNIX for Dummies Questions & Answers

Q about windows bat files

Hi, can you run a windows bat file or a VBscript from a shell script? #!/bin/sh PATH=/ $PATH/test.bat (1 Reply)
Discussion started by: cmac
1 Replies

6. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

7. Windows & DOS: Issues & Discussions

Urgent Need for Assistance: Triggering Windows bat files from UNIX

Hello, Is there a way to trigger a Windows bat file or program on a different machine from a different UNIX server using KSC file? I hope you can assist me with this. Thanks! (0 Replies)
Discussion started by: punyenye
0 Replies

8. Shell Programming and Scripting

Is writing shell scripts different than...

I am currently taking a linux shell scripting class and also a intro to programming class using QBASIC. Will this interfere with how i learn each one? Are they similar in some ways? I already took a unix course based on the commands and it was easy, but now i have to create programs. Also, how... (1 Reply)
Discussion started by: brentdeback
1 Replies

9. Shell Programming and Scripting

FTP Shell Scripts from Windows to Unix: files have exotic characters

Hey guys, I am working on my shell scripts in wordpad in windows. Then, I upload it to my unix using psftp, but when I open those files with "vi" in Unix, there are all these "^M" characters in the file. Would anyone of you have a clue as to why? Help would be appreciated. Thanks, Laud (4 Replies)
Discussion started by: Laud12345
4 Replies

10. UNIX for Dummies Questions & Answers

help for newbie writing shell scripts

Hi, I have just started a Systems Programming course and am required to write a c shell script as part of it. I have little to no clue about unix. The spec states that the script can be run only once on each host by a user, but the script can be run on different hosts by the one user. ... (2 Replies)
Discussion started by: richgi
2 Replies
Login or Register to Ask a Question