New to Unix, need help with shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers New to Unix, need help with shell script
# 1  
Old 07-14-2008
New to Unix, need help with shell script

I am writing a very basic shell script, and I have never really written anything in UNIX before.

here is what I have:

#!/bin/ksh

set P = 045
set R = 001
for $R < $P
RPT = report005_${R}.lis
PDF = report005_${R}.pdf
/home/pcl2pdf $RPT $PDF
add 1 to $R
done

basically, I need to run this loop 44 times. Each time, it will set the report and PDF names, then run the command below (which converts the .lis file to a .pdf file). When complete, I need to increment the counter.

This script is not working, and without any documentation or knowledge of UNIX, I am stuck. Can someone assist with this script please?

Thank you in advance.

Mark
# 2  
Old 07-14-2008
Here's an example to do a loop of 44 times:

Code:
for i in `seq 1 44`
do
  # do your stuff here
done

But if you're not familiar with scripting, you really should read some tutorials:

https://www.unix.com/answers-frequent...tutorials.html

Regards
# 3  
Old 07-14-2008
on eproblem i see is you should not put spaces in variables. and no spaces around the = sign.

P=045
R=001

would allow you to call $P and $R

do the same for all the vars.
# 4  
Old 07-14-2008
Thanks everyone for your help. I almost have this working

Here is my last issue.

I set the one variable, and add to it

suf=`expr $suf + 1`

I always need my variable to be 3 characters, and zero filled. I did search, and found a TYPESET -Z which will right justify the value, and 0 fill it, but I am not sure if this is what I am looking for.

any suggesstions?

Thanks
# 5  
Old 07-14-2008
Hammer & Screwdriver one way to get three digits...

Code:
> s_value=12
> echo $s_value
12
> s_value_t=$(printf "%.3d" "$s_value")
> echo $s_value_t
012

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

4. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

5. Shell Programming and Scripting

FTP from windows to unix server using unix shell script

Hi, Is it possible to ftp a huge zip file from windows to unix server using unix shell scripting? If so what command i need to use. thanks in advance. (1 Reply)
Discussion started by: Shri123
1 Replies

6. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

7. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

8. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

9. 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

10. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies
Login or Register to Ask a Question