Operating System - HP-UX
1820614 Members
1855 Online
109626 Solutions
New Discussion юеВ

Re: How can i create an script ?

 
SOLVED
Go to solution
Martin Napoli_1
Occasional Advisor

How can i create an script ?

I've found the following script to do tape-to-tape copy but I don't know how to create it.

while true
do
dd if= of= bs=128k
if [[ $? -ne 0 ]];
then break
fi
done

Any help will be appreciated!

Thanks in advance.
Martin
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: How can i create an script ?

create a file.

vi scriptname.

Include a shell at the top such as

#!/usr/bin/sh

or

#!/usr/bin/ksh

copy in your text.

Shift ZZ to save it

chmod a+x scriptname

Now it is excecutable by all.

Then test it.

P
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ricardo Bassoi
Regular Advisor
Solution

Re: How can i create an script ?


Hi Martin,

Create a script is a simple task. A script is a text file that "glue" the unix command lines in a program block.

To create one with your information do the following:

1- Call the vi editor:
# vi scriptname

If you don??t know vi is better to do a:
# man vi

2- Use a header in the first line
#!/bin/sh

Check if this path exist !

3- Copy the text that you have and after finnish the command block with
exit 0;

4- Save the script and give execute permissions:

# chmod +x scriptname

5- To do a debug do:

# sh -x scriptname

Regards,

Ricardo

If you never try, never will work
Robin Wakefield
Honored Contributor

Re: How can i create an script ?

Hi Martin,

If you'd rather not "vi" it, you can simply type:

cat <<'EOF' > yourscriptname
while true
do
dd if= of= bs=128k
if [[ $? -ne 0 ]];
then break
fi
done
EOF

The single quotes around the EOF in the 1st line stop the $? from being interpreted. I'd learn vi though, there aren't that many basic commands!

Rgds, Robin.
Juan Manuel L├│pez
Valued Contributor

Re: How can i create an script ?

Create a script is very easy. Think that a script is just put commands on a file and make that file executable.
If you want to use forms like "if" of " for " you have to begin your script with #!/usr/bin/ksh
To indicate the shell you want to use.
There arr a lot of information about shell script in internet where you can find examples and more.
I hope to this help you.
I would like to be lie on a beautiful beach spending my life doing nothing, so someboby has to make this job.
Stanimir
Trusted Contributor

Re: How can i create an script ?

Hi!
In addition to all you must:
1.Find the device file of tape1-drive
and tape2-drive,
usually in dir /dev/rmt and
put these files nstead of
and .
2.Please use: #man dd
and you can know more about option bs and
more.

Steve Steel
Honored Contributor

Re: How can i create an script ?

Vicente Sanchez_3
Respected Contributor

Re: How can i create an script ?

Hi,

Another place to look for scripting information:

www.shelldorado.com

Regards, Vicente.