Log in, run program


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Log in, run program
# 1  
Old 12-03-2009
Log in, run program

Hey, im editing the passwd file so that when the user ben logs in it runs my assign program.

I changed the last column from
Quote:
/home/ben:/bin/bash
to
Quote:
/home/ben:/home/ben/assign
Then when i log in i get...

Quote:
/home/ben/assign: line 194: `func_Menu1.1': not a valid identifier
Connection closed by foreign host.
There is no problem with the program because it runs fine when i open it normally.

Any help much appreciated.
# 2  
Old 12-03-2009
Maybe there's no syntactical problem with your program, but most certainly a logical: the login programs have almost no environment set. All those nice path variables, aliases, ... are set by the shell when it's invoked as a login shell. Without that, you'll have to do it yourself.
# 3  
Old 12-03-2009
Quote:
Originally Posted by pludi
Maybe there's no syntactical problem with your program, but most certainly a logical: the login programs have almost no environment set. All those nice path variables, aliases, ... are set by the shell when it's invoked as a login shell. Without that, you'll have to do it yourself.
I see, is there a way of opening the bash then the assign program?
# 4  
Old 12-03-2009
You've got 3 options:
  1. Find out what environment variables are needed and set them yourself
  2. Source the login scripts yourself at the beginning of your script (/etc/profile, /etc/bash.profile, ~/.bashrc, ...)
  3. Invoke bash with the -l switch. From the man page of bash:
    Quote:
    -l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
# 5  
Old 12-04-2009
Quote:
Originally Posted by pludi
You've got 3 options:
  1. Find out what environment variables are needed and set them yourself
  2. Source the login scripts yourself at the beginning of your script (/etc/profile, /etc/bash.profile, ~/.bashrc, ...)
  3. Invoke bash with the -l switch. From the man page of bash:
I am a real beginer at this so what would you recomend, 3?

Were am i supposed to use the -l? In my script or in the passwd file?
# 6  
Old 12-04-2009
The cleanest solution would be 1, as you'll only define what you really need. This can help a lot if you need to debug it, as it cuts down massively on external influences.

3 is the easiest, and any changes you do to system settings are immediately visible on next log on. As for where to use it: best would be the she-bang line, to that it reads
Code:
#!/bin/bash -l

In case it's not distinguishable with your font: that's a lowercase 'L', not an uppercase 'i'.
# 7  
Old 12-07-2009
Thanks,

Would that be in the passwd file or program itself?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't get my program to run -- GC calculator?

have been trying for a few weeks not to get this program running. I am newer to programming and it has definitely been a challenge. I think my problem arises with my if statement. I can get it to append the name to the new file, but it simply appends the whole sequence to the file rather than... (3 Replies)
Discussion started by: haley6719
3 Replies

2. Shell Programming and Scripting

Run a program as another user

I have a bash script that launches another problem. I need to run that program under a certain user account. The script itself is run using 'sudo <scriptname>'. #!/bin/bash myprogram=... exec "$myprogram" How would this be done? (1 Reply)
Discussion started by: Carson Dyle
1 Replies

3. UNIX for Dummies Questions & Answers

Help to run this socket program in C

i have created two files named server and client then when i run the server program it says the server is waiting(./server 5555) then when i run the client program it says "client error:connection refused" can u plz help me to run it?:( (7 Replies)
Discussion started by: kedah160
7 Replies

4. Shell Programming and Scripting

Make program only run by root

Hi all, i hope i got this in the right place, what i am trying to do is make a program only run by root, ie for instance user fred is logged in and uses firefox, what id like to do is change that so that when fred wants to use firefox he will be asked to enter root password before he is allowed to... (14 Replies)
Discussion started by: dave123
14 Replies

5. Programming

Compile and Run C Program on Solaris

Hello Guys, I am using Solaris Developer Express Edition 9/07, I am a beginner. Please tell me how to compile and execute a C program. Please give me your answers clearly, for the compilers cc,c89,c99. I not getting the answer anywhere. Please....... reply to me. Advance thanks......... (0 Replies)
Discussion started by: selva_ss
0 Replies

6. UNIX for Dummies Questions & Answers

cannot run program

Hi, I have a program in /opt/local/bin, my path in my .profile is export PATH=/opt/local/bin:/opt/local/sbin:$PATH however when i type the program name it cannot find it, however i know the program is in /opt/local/bin? Thanks (2 Replies)
Discussion started by: c19h28O2
2 Replies

7. Shell Programming and Scripting

how can i run java program from any where

Hello all sorry didnt know where to post it i compiled simple program that using "System.getProperty("user.dir");" now i compiled the program under directory foo and and its running great when i do "java myapp" i included this directory in the $PATH env variable so i could see it fro any where... (1 Reply)
Discussion started by: umen
1 Replies

8. UNIX for Dummies Questions & Answers

How do i run a program while in Unix?....

Im new and wanted to know if im in the unix terminal and lets say i want to run microsoft word for example. i go in and go into the HD and then keep going and i type ls and see that microsoft word.app is there. how do i run it from that? (4 Replies)
Discussion started by: Corrail
4 Replies

9. UNIX for Dummies Questions & Answers

Getting a program to run

Please help, I have tried to run this program countless times and still nothing. Please tell me what I'm doing wrong. $ cat>test count=1 while do echo "5" read number echo $5 let count=count+ 1 done exit 0 ^C$ ksh test $ ^C $ ksh test $ $ nothing happend (6 Replies)
Discussion started by: ctiamaria
6 Replies

10. Programming

how to run debugging on c program

Can someone help me debug a c program I am running? It gives me segmentation fault. I want to turn on debugging. Can some one give the command to turn it on? Below is the error I get: Segmentation Fault (core dumped) (3 Replies)
Discussion started by: ibeg
3 Replies
Login or Register to Ask a Question