LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2020, 09:49 AM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 115

Rep: Reputation: 19
environment variable does not exist


Code:
$ p=password; ccrypt -eEp file.txt 
ccrypt: environment variable p does not exist.
$ user@cloudm:~/tmp/test10$ export p=password; ccrypt -eEp file.txt 
$ t=test; echo $t
test
ccrypt reads the password from p, but it sees it only when p is exported. Why?

Last edited by doru; 09-23-2020 at 07:26 AM.
 
Old 09-22-2020, 09:54 AM   #2
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 115

Original Poster
Rep: Reputation: 19
ccrypt works in some kind of subshell and it does not care to read the variable before it creates the subshell?!
 
Old 09-22-2020, 10:26 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,142
Blog Entries: 13

Rep: Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216Reputation: 4216
Not sure, but you might have to use that "cat<<EOF" bash notation there. I'm pretty weak on that notation.

https://mytrashcode.com/cat-command-examples
 
Old 09-22-2020, 10:28 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,881

Rep: Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250
wrong syntax:
Code:
p=password ccrypt -eEp file.txt
without ; will work, but with ; it won't.
otherwise export makes the given environment variable[s] accessible in the child processes. That is the purpose of that export.

Last edited by pan64; 09-22-2020 at 10:30 AM.
 
Old 09-22-2020, 05:58 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,928

Rep: Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500Reputation: 4500
Expanding on the explanation above:

Quote:
Originally Posted by doru View Post
Code:
$ p=password; ccrypt -eEp file.txt
Well, with the semicolon, that's exactly equivalent to:

Code:
$ p=password
$ ccrypt -eEp file.txt
Do you see the problem?
 
  


Reply

Tags
assignment, shell, variables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Selenium: Check whether button exist or not and if exist whether the the text is in it is desired one or not daichiash General 0 07-03-2020 11:17 AM
[SOLVED] cannot login to funtoo linux. UID 0 does not exist. no users or groups seem to exist. whansard Linux - Security 1 12-19-2018 04:40 AM
Environment variable that dynamically changes when another variable is changed youtoo Linux - Newbie 4 02-17-2016 02:44 AM
Error : Group GNOME Desktop Environment does not exist. afsarie Linux - Desktop 1 03-15-2014 06:12 AM
Is there any ROOTPATH environment variable exist in RH5 Linux? nagendrar Linux - Newbie 2 08-26-2011 02:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration