I am 100% new to Unix and trying to learn.
This is my first time even touching a script in Unix.
We have the following variable script that I am trying to run....
Now if I try to excute this by the following....
./logintest.sh
It just goes right back to a bash-3.00$ prompt and does nothing.
If I try it this way....
sh logintest.sh I get this....
logintest.sh: PS1=${Hostname}:${PWD}>: is not an identifier
Now if I do a more on this file and then do a highlight with a right click to place the commands directly in then it works just fine. Also the perms are set to 777.
Could anybody please tell me what I am doing wrong? I am really lost here.
when you write a script, then execute it, the script runs as a child process. Any changes you make to the environment (variables are part of the environment) are made to the child's envrionment. When the child exits at the end of the script, you revert back to the parent environment. All child changes are lost.
<dot space>script.sh - means runs this in the parent envrionment. This is called sourcing. bash supports a builtin function, source, which is the same as the dot thing.
When you source some script, environment changes are kept in the same process, the parent. .bashrc or .profile are run when you login - they are sourced.
Ok so what your saying is that this indeed running expect that after the run because its a child its going back to before the run so fast that it looks as if it never ran? I think I got that right.
No. Parent has memory with variables in it. Child inherits new copy of memory with identical memory. Child changes memory. Child exits. Child memory ceases to exist. Parent memory takes over again, but never, ever was changed. Parent cannot know about child changes.
Please help me to understand the issue:
Issue: There are shell scripts in a user home directory (/home/user_1)
without execute permissions (rw-r--r--) to owner,group and world
These shell scripts were able to execute/work previously but its not working now and it says permission denied or... (2 Replies)
hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view
situation
a router, with linux of some sort,
dhcp client requesting for ip in wan1 (as usual with wan ports)
dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
My script work on Linux but not work in sun os.
my script.
logFiles="sentLog1.log sentLog2.log"
intial_time="0 0"
logLocation="/usr/local/tomcat/logs/"
sleepTime=600
failMessage=":: $(tput bold)Log not update$(tput rmso) = "
successMessage="OK"
arr=($logFiles)... (7 Replies)
I have a client machine that was built and loaded with SCO UNIX 2.1.3, (yes it is old). The machine worked fine on the closed network that I tested on in my shop. I then had to change it to the network that it would be connected to. Below is the host file, router and subnet mask file that I usually... (0 Replies)
i wish to have a shell script which receives the file name and path (from the user) to a text file that contains a c program and compiles the program code using gcc and displays the execution of the compiled file (which is saved as filename.c) in the terminal / konsole
Can any one help me by... (1 Reply)
Hi All
I have a file containing the following information
SOURCESERVER DESTINATIONSERVER DESTINATIONENVIRONMENT CONDITION
I was trying to read and then execute the conditions,like if SOURCESERVER is XXXX0001 and the DESTINATIONSERVER is XXXX0002 and the DESTINATIONENV is YYY the... (3 Replies)
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)
Howdie everyone...
I have a shell script RemoveFiles.sh
Inside this file, it only has two commands as below:
rm -f ../../reportToday/temp/*
rm -f ../../report/*
My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
:cool:
I need to execute a shell script to do the following:
cat a file
run two back ground processes using the first two values from the file
wait till those background processes finish
run two more background processes using the next two values from the file
wait till those background... (1 Reply)