PHP Developers Network
http://forums.devnetwork.net/

export is not working on command prompt
http://forums.devnetwork.net/viewtopic.php?f=30&t=120426
Page 1 of 1

Author:  devarishi [ Thu Aug 26, 2010 6:47 pm ]
Post subject:  export is not working on command prompt

Hi,


The command export is working inside a shell script, but when I type it at the command prompt / terminal it doesn't work. "export: The command not found" error is displayed instead.

I tried this:

cat test.sh

Syntax: [ Download ] [ Hide ]
abc=123
export abc
echo "Exit status of export abc: $?"


Syntax: [ Download ] [ Hide ]
# bash test.sh
Exit status of export abc: 0


But when I type it at the command prompt:

Syntax: [ Download ] [ Hide ]
# export abc=123


I get the "the command not found" error.

Syntax: [ Download ] [ Hide ]
man export
is also working fine.

I tried it before on my RHEL system and it was working. I have checked the $PATH variable also it is okay. What could be the problem?

Author:  devarishi [ Sat Aug 28, 2010 1:02 pm ]
Post subject:  Re: export is not working on command prompt

The problem is solved now. So, I want to post here the solution I found:

I have just found that my shell got changed to csh and it was creating the problem.

Syntax: [ Download ] [ Hide ]
[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/csh


I changed it to bash and the problem was resolved!

Syntax: [ Download ] [ Hide ]
[root@localhost ~]# type export
export is a shell builtin



I experimented with these commands:

Syntax: [ Download ] [ Hide ]
[root@localhost ~]# csh
[root@localhost ~]# type export
type: Command not found.
[root@localhost ~]# bash
[root@localhost ~]# type export
export is a shell builtin
[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/bash
 



The problem has taught me some troubleshooting techniques

Syntax: [ Download ] [ Hide ]
type <command> <enter>


and first where to check when a command is not working, i.e. the log-in shell.

Syntax: [ Download ] [ Hide ]
grep ^"$USER" /etc/passwd


or

Syntax: [ Download ] [ Hide ]
echo $SHELL

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/