Paste Script Help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Paste Script Help
# 1  
Old 01-17-2007
Paste Script Help

Below is a simple script that allows the use of the Unix paste utility. However, when I try and run the script, it gives me the following errors:

pastescript: ^M: not found
pastescript: ^M: not found
pastescript: syntax error at line 24: `in^M' unexpected

Could anyone tell me what's wrong with this? Any help would be appeciated.
Code:
while [ 5 -eq 5 ]
do
clear
print "
---------------------------------------------------
    menu
--------------------------------------------------- "

print "This is menu"
        print "\n"
        print " 1:  menu1"
        print " 2:  menu2"
        print "\c"
        print " 3:  menu3"
        print "\c"
        print " 4:  menu4"
        print "\c"
        print " 0:  Exit the Program"
        print "\c"

case "$case1" in



        1)

print " hit enter for menu"
;;



        2)
        
print "hit enter for menu"
        ;;


        3)
        print "enter some files to paste"
read a b

 
print " ----------------------------------------------------------------- "
print "
        1) (delete this- wrtie a paste option here)
        2) same
        3)



 \n"



        print "Enter a PASTE option (number) : \c"
        read paste2

        case "$paste2" in

  1)
      paste $a $b 
echo hit enter for menu
;;
  2)
      paste $a $b 
echo hit enter for menu
      ;;

  3) paste $a $b 
echo hit enter for menu
;;
 


  *) #if no Numerical option is selected - display this error messag

    print "You DID NOT select a Numerical option"
echo hit enter fro the menu
    ;;
        esac

    ;;

        4)# number 4 from first case
        
        ;;





5)
        
;;


        0)
        exit
                ;;

        *)
        # CASE
        clear
print "
---------------------------------------------------
    Menu
--------------------------------------------------- "

print "This is menu"
        print "\n"
        print " 1:  menu1"
        print " 2:  menu2"
        print "\c"
        print " 3:  menu3"
        print "\c"
        print " 4:  menu4"
        print "\c"
        print " 0:  Exit the Program"
        print "\c"
echo choose an option
        ;;

*)
# This is the last line that displays:
echo choose an option
;;

esac
read case1

done


Last edited by blowtorch; 01-17-2007 at 11:03 PM.. Reason: code tags
# 2  
Old 01-17-2007
Dangrim1, please use code tags to make your scripts and posts more readable. And there is likely nothing wrong with your script whatever. You just need to run the dos2unix/dos2ux command on your script.

On Solaris (and possibly Linux):
dos2unix script_name script_name

On HP-UX
dos2ux script_name > script_name.tmp; mv script_name.tmp script_name
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Paste command not working in shell script

Hai , When i use paste command in command prompt its giving expected output but not in the script. Below is the example. $cat file 1 2 3 $cat file1 4 5 6 $paste -d ':' file file1 1:4 2:5 3:6 but when i used the same command in script its giving the output as below : 1 2 3 (3 Replies)
Discussion started by: Subbu123
3 Replies

2. Shell Programming and Scripting

Use of the PASTE command in a script file

Hi, When I use the paste command in the terminal window it works fine, but when i try to use it in a bash script file i get errors. I'm not sure how to use the paste command in a bash script file. my paste command looks like this paste <( code1 ) <(code2) thanks (7 Replies)
Discussion started by: eboye
7 Replies

3. Shell Programming and Scripting

How to paste lines below certain text (Script)

Hello Guys, I know the command echo " " > filenamehere ; would erase everything in the document. Can the same be done, to paste words below certain text? For example, lets say i want to paste a line below the line Server name: in apache.conf . What should be added in the script? (8 Replies)
Discussion started by: xxxx
8 Replies

4. Shell Programming and Scripting

Paste the files

Dear All, I have thousands of files (consists of one column each) and i need to paste all the columns in a single file as follows: I have files - file1, file2, file3, .......file2000. I need to paste all the files in a single file of separate columns as shown below: file1 file2 file3 ... (3 Replies)
Discussion started by: Fredrick
3 Replies

5. UNIX for Dummies Questions & Answers

Paste

paste -d "\0" ap_cntrl_total.txt.1 ap_cntrl_total.txt.2, and it shows: 01234567890911051342C091026 0000910517990000000000009105179900000000CHOPME it put space btwn 1026 and 000091 should not have space. ---------- Post updated at 03:54 PM ---------- Previous update was at 03:03 PM... (1 Reply)
Discussion started by: tjmannonline
1 Replies

6. Shell Programming and Scripting

cut and paste?

hi, I have a file with content like this for an employee: EmployeeID 101 Day_type, day vacation,1/2/2009 sick day, 3/2/2009 personal day, 4/5/2009 jury duty day, 5/5/2009 how do I make the result to show: EmployeeID,Day_type,day 101,vacation,1/2/2009 101,sick day,... (6 Replies)
Discussion started by: jbchen
6 Replies

7. Shell Programming and Scripting

How to copy and paste line in shell script

Hi I want to grep for a line and copy and paste that line. for Example ---- file abc.txt ---- host=atlx1 sid=atld1 mail=abc@abc.com host=atlx2 sid=atld2 mail=xyz@abc.com host=atlx3 sid=atld3 mail=def@abc.com host=atlx4 sid=atld4 mail=mno@abc.com --- end of file abc.txt ---- Now I... (16 Replies)
Discussion started by: upsrk
16 Replies

8. Shell Programming and Scripting

aside from paste

how can i make a script or command to have output like this $cat file 10000 20000 $cat a 10000 $cat b 20000 this is the solution paste a b > file but another solution? $cat file 10000 20000 (3 Replies)
Discussion started by: kenshinhimura
3 Replies

9. Shell Programming and Scripting

Perl script assistance; paste word into external command

I'm attempting to create a Perl script that will: Take the contents of the usernames.tmp file (usernames.tmp is created from an awk one-liner ran against /etc/passwd) Take one line at a time and pass it to the su command as a users name. This should go on until there is no more name to... (10 Replies)
Discussion started by: bru
10 Replies

10. Shell Programming and Scripting

Paste script for Unix!

I really need to make a paste script to ease and simplify the UNIX paste facility. I really have NO idea where to start, other than the first line initializing the korn shell. I'd like the script to be interactive, with options and file names being imputted after the pograms prompts! Any help... (0 Replies)
Discussion started by: Dangrim1
0 Replies
Login or Register to Ask a Question