LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 08:49 AM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

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 06:26 AM.
 
Old 09-22-2020, 08:54 AM   #2
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

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, 09:26 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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, 09:28 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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 09:30 AM.
 
Old 09-22-2020, 04:58 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,222

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
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



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 10: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 03:40 AM
Environment variable that dynamically changes when another variable is changed youtoo Linux - Newbie 4 02-17-2016 01:44 AM
Error : Group GNOME Desktop Environment does not exist. afsarie Linux - Desktop 1 03-15-2014 05:12 AM
Is there any ROOTPATH environment variable exist in RH5 Linux? nagendrar Linux - Newbie 2 08-26-2011 01:45 AM

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

All times are GMT -5. The time now is 04:05 PM.

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