Script that also create a script, how can i save it?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that also create a script, how can i save it?
# 1  
Old 10-25-2010
Script that also create a script, how can i save it?

say i have a script that says

cat > resultofsample.sh
#!/bin/bash
codes

but how can i exit it from here and save it?
# 2  
Old 10-25-2010
in vi mode, type the fllowing:
Code:
:wq!

# 3  
Old 10-25-2010
Type CTRL+D to signal EOF.
# 4  
Old 10-25-2010
Press Ctrl+d to save and exit. This should be done in the new line i.e line after the word codes
Code:
cat > resultofsample.sh
#!/bin/bash
codes
Ctrl+d

# 5  
Old 10-25-2010
seems not working. i'm stuck to an empty shell without a prompt.

lets say i have this whole script.

Quote:
#!/bin/bash
ls -l
cat > resultofsample.sh
#!/bin/bash
codes
Ctrl+d
the script must create a script named resultofsample.sh
which supossedly have these codes
Quote:
#!/bin/bash
codes
Ctrl+d
it did create the script but its empty.
# 6  
Old 10-25-2010
Did you type 'crtl + d' or did you press 'D' key while holding down the 'Ctrl' key ? It should be the latter.
# 7  
Old 10-25-2010
Im not sure how to execute Ctrl + d within a script. But could try as below
Code:
#!/bin/bash
ls -l
#cat > resultofsample.sh
echo "#!/bin/bash" >resultofsample.sh
echo "codes" >>resultofsample.sh

This User Gave Thanks to michaelrozar17 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

Expect script to save configuration from a router

Hy guys, My name is Alex, i am new here and I hope to find some answers. I am trying to run a expect script to telnet to a mikrotik router, run a command (export), and save the output of that commant to a file (outputfile.txt). The problem is that only part of the output is saved to... (2 Replies)
Discussion started by: axexandru
2 Replies

3. Shell Programming and Scripting

Script to scrape page for and save data

Hi All I would like to get cars DB from this web site link removed , and I am trying to right script to go and parse the web page and save the data for each cars into a file, type of cars, mark, model, but when I look to the source page I found out that the first car type is preselected and the... (3 Replies)
Discussion started by: molwiko
3 Replies

4. Shell Programming and Scripting

Save output to file - inside a script ?

I'm using the following script to check cisco router health and I'd like to save output to a file, vty_runcmd.sh > /check/check-cisco-health script works and output is saved to a file. However using it in crontab file is created but output is not printed inside it. In crontab, */5 * * * *... (4 Replies)
Discussion started by: marmellata
4 Replies

5. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

6. Shell Programming and Scripting

open file and save as script

hi guys i have a problem with my file did not work as usual. The problem is i need to open the file and save as using same name and after that the file is work properly. Is it any shell script can do open the file and save as using same name..because i have thousand of file with the same problem (3 Replies)
Discussion started by: zulabc
3 Replies

7. UNIX for Dummies Questions & Answers

How to save a shell script in Uwin

Hi All, Actually im new to Unix and trying to learn shell scripting in uwin(freeware) on windows xp machine. I tried writing the shell script with vi mode, but my problem is I am unable to save this script file even after specifying :wq option ie I am unable to save the file and quit from vi mode... (1 Reply)
Discussion started by: vikkram
1 Replies

8. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

9. UNIX Desktop Questions & Answers

script to save file

Hello evry1, Trying to come up with a script that picks content from another file, and saved the new file with the original file name but adding the time when the script is run to the new file name. after which it compresses this new file. Thanks in advance (1 Reply)
Discussion started by: Targ
1 Replies

10. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question