The original Script change after execute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting The original Script change after execute
# 1  
Old 03-01-2007
The original Script change after execute

Dear all,

I'm new in unix system and now try to study script, I have write script :
#!/bin/ksh
#how to check positional argument handling
echo "\$0 = $0"
echo "loop over \$*"
for a in $* ; do
echo \"$a\"
done
echo " loop over \"\$@\""
for a in "$@"; do
echo \"$a\"
done
#exit


and after change to execute file, I open again and change to :

# !/bin/ksh
# how to check positional argument handling
echo " Number of argument : 0"
echo "$0 = /sbin/sh"
echo " loop over $*"
for a in ; do
echo \"\"
done
echo " loop over \"$@\""
for a in ""; do
echo \"\"
done
# exit


any one can help me why this happened and how to start learn script ?

Thank you before


Regards,


Heru
# 2  
Old 03-01-2007
Sorry, What is your question here?

If you are looking for the diff b/w $* and $@,
$* -> All of the positional parameters, seen as a single word
$@ -> Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word
# 3  
Old 03-01-2007
Quote:
Originally Posted by heru_90
Dear all,

I'm new in unix system and now try to study script, I have write script :
#!/bin/ksh
#how to check positional argument handling
echo "\$0 = $0"
echo "loop over \$*"
for a in $* ; do
echo \"$a\"
done
echo " loop over \"\$@\""
for a in "$@"; do
echo \"$a\"
done
#exit


and after change to execute file, I open again and change to :

# !/bin/ksh
# how to check positional argument handling
echo " Number of argument : 0"
echo "$0 = /sbin/sh"
echo " loop over $*"
for a in ; do
echo \"\"
done
echo " loop over \"$@\""
for a in ""; do
echo \"\"
done
# exit


any one can help me why this happened and how to start learn script ?
How did you write the script? Did you write it at the command line? If so, the variables would be expanded befopre being saved to the file. You should use a text editor (I recommend emacs, but for starting out, pico or nano may be less intimidating).
# 4  
Old 03-01-2007
Quote:
Originally Posted by jacoden
Sorry, What is your question here?

If you are looking for the diff b/w $* and $@,
$* -> All of the positional parameters, seen as a single word
That is not the case. If $* is quoted ("$*"), then all the positional parameters are seen as a single argument. Unquoted, each word in the positional parameters is treated separately.

Quote:
$@ -> Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpretation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word
# 5  
Old 03-02-2007
Thank's for all

Yes, I mean why variabel change, and from the answer that cuase i'm using command line to make script. I think that solution, thank's for your help. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

perl script to replace the text in the original file

Hi Folks, I have an html file which contains the below line in the body tagI am trying the replace hello with Hello Giridhar programatically. <body> <P><STRONG><FONT face="comic sans ms,cursive,sans-serif"><EM>Hello</EM></FONT></STRONG></P> </body> I have written the below code to... (3 Replies)
Discussion started by: giridhar276
3 Replies

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

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. UNIX for Dummies Questions & Answers

command to change original file

I have a script where I have the command sed "s/$search_string/$replace_string/g" $backup However I want a command to correct the original file $backup as well as creating another file with the changes which I have in my script already. In other words, I want to touch the orginal file also... (1 Reply)
Discussion started by: alis
1 Replies

6. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

7. Shell Programming and Scripting

Change: xecho: execute permission denied error

Hello, I am have an issues with one of my scripts. I get the following error when I get to the point in the script where I am making the change. The change does take however. the error is "change: xecho: execute permission denied" Everything was working properly until I start cleaning... (3 Replies)
Discussion started by: simpsonjr
3 Replies

8. UNIX for Dummies Questions & Answers

auto change x screen and execute script

Hi there, I've been looking all day, but could not find anything helpfull, so I hope you can help me. When my system now starts up, the Xwindow is automaticly started and i get the log on screen (which is x screen 7 if I'm correct) Now what I would like is on startup that instead of going to... (1 Reply)
Discussion started by: Wonderke
1 Replies

9. Shell Programming and Scripting

Change user on remote machine and execute script!

Hi, I need to login into remote server and execute a shell script over there. As of now i am making use of ssh command ssh primUser@135.254.242.2 sh /poll.sh I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible. ... (5 Replies)
Discussion started by: goutham4u
5 Replies

10. Shell Programming and Scripting

script execute or no execute

o hola.. Tengo un script que se ejecuta bajo una tarea del CronJOb del unix, tengo la version 11 de unix, mi script tiene un ciclo que lee unos archivos .txt luego cada uno de esos archivos debe pasar por un procedimiento almacenado el cual lo tengo almacenado en mi base de datos oracle 10g,... (4 Replies)
Discussion started by: Kespinoza97
4 Replies
Login or Register to Ask a Question