Sponsored Content
Top Forums Shell Programming and Scripting Parse variables from C++ to shell Post 302901304 by linuxUser_ on Tuesday 13th of May 2014 08:36:48 AM
Old 05-13-2014
Quote:
Originally Posted by chacko193
Dont know how to make the directory, but the rest can be done using this:
Code:
#include <iostream>
#include <fstream>

using namespace std;

int main() {
        int var =34;
        ofstream varFileOut;
        varFileOut.open("varFile");
        varFileOut <<var<<endl;
        varFileOut.close();

        var = 43;
        ifstream varFileIn;
        varFileIn.open("varFile");
        varFileIn >> var;
        varFileIn.close();

        cout<<"Var is: "<<var<<endl;
        return 0;
}

Thankyou... source("mkdir dirName") will work for creating directory Smilie

---------- Post updated at 06:06 PM ---------- Previous update was at 05:52 PM ----------

how can i save in a loop... lets say im running a for loop. in that loop i wanted to open that file and write for every iteration without overwriting.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to parse config variables from external file to shell script

How do i use a config.txt to recursively pass a set of variables to a shell script eg my config.txt looks like this : path=c://dataset/set1 v1= a.bin v2= b.bin path=c://dataset/set2 v1= xy.bin v2= abc.bin .................. and so on . and my testscript : (2 Replies)
Discussion started by: pradsh
2 Replies

2. Shell Programming and Scripting

How can I parse a record found in /etc/passwd into variables?

I am working with the Oracle 10.2.0.3 job scheduler on Solaris 10, and unfortunately, the scheduler executes scripts in such a way that several default shell environment variables are not defined. For example, $HOME, $USER, and $LOGNAME are missing. How can I parse the appropriate record in... (7 Replies)
Discussion started by: shew01
7 Replies

3. Shell Programming and Scripting

How to: Parse text string into variables using Korn shell

I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
Discussion started by: shew01
7 Replies

4. Shell Programming and Scripting

Parse for errors shell script

All, I have a shell script which parses the /var/adm/messages file for errors every 15 minutes as a cron job. The script runs at 01, 16, 31, and 46 minutes every hour. The problem is if the error is encountered any time during the beginning of hour I can get paged three times. I would like to... (2 Replies)
Discussion started by: bubba112557
2 Replies

5. Shell Programming and Scripting

How to parse a string into variables

I'm working in korn shell and have a variable which contains a string like: aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies

6. Shell Programming and Scripting

Want to parse output for variables in Bash

Trying to finish up my script that automates some video encoding work. Situation: There is an MKV file to be transcoded. Problem: MKVINFO will give a bunch of output about an MKV file, included in that output are two lines I am interested in: | + Default duration: 41.708ms (23.976 fps... (9 Replies)
Discussion started by: randyharris
9 Replies

7. Shell Programming and Scripting

Parse config file and store the values in variables

Hi, I have a config file that has blank, commented lines. I need to escape commented lines, blank lines, parse the remaining lines and store them in variables or array. the config file contains the following lines. # config file # Define Oracle User ORA_USER=abcde ORA_PASS=xyzabc... (8 Replies)
Discussion started by: Lakshmi Chowdam
8 Replies

8. UNIX for Dummies Questions & Answers

Parse or cut concat variables to individual values

Hello I need to pass some environment parameters to a datastage job and am getting an error when trying to send the complete concatinated variable. I have decided to parse out just the values and send as parameters but am struggling to find the best way to do this (actually I am not very... (3 Replies)
Discussion started by: LynnC
3 Replies

9. Shell Programming and Scripting

Need to parse lines in a file into two words and assign the values to two variables

For example, I have a file with below lines containing VOB tags and VOB paths. * /vobs/fts/FTSUSM20_VOB /ccvobsslx01/projects/vobs/eml/FTSUSM20_VOB * /vobs/fts/FTS20_VOB /ccvobsslx01/projects/vobs/eml/FTS20_VOB * /vobs/pmv/PMS_VOB /ccvobsslx01/projects/vobs/cpm/_/PMS_VOB *... (4 Replies)
Discussion started by: senthilkc
4 Replies

10. Linux

Parse ; deliminated variable to create variables

Hi there, would appreciate some help on this parsing problem if anybody can help im trying to parse a variable with the following output, each of the values im trying to parse are deliminated by a ; T192... (8 Replies)
Discussion started by: scottish_jason
8 Replies
FBB::StringLine(3bobcat)					  Line extractor					  FBB::StringLine(3bobcat)

NAME
FBB::StringLine - extracting lines using operator>> SYNOPSIS
#include <bobcat/stringline> DESCRIPTION
The standard operator>>(std::istream &, std::string &) string extracion operator extracts the first `word' from a stream. In cases where the intent it to extract lines from the stream this operator cannot be used, but getline(std::istream &, std::string &) is usually called. However, getline is not called by many tools of generic algorithms, like the istream_iterator. The class (actually: struct) StringLine was simply derived from std::string, and defines its own operator>>, reading the next line from the specified std::istream. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
std::string CONSTRUCTORS
StringLine is an empty shell around std::string. It does not explicitly define constructors. The default and copy constructors are avail- able. OVERLOADED OPERATOR
o std::istream &operator>>(std::istream &in, StringLine &str): The extraction operator returns the next line on in in str, calling getline(std::istream &, std::string &). MEMBER FUNCTIONS
All members of std::string are available, as FBB::StringLine inherits from these classes. EXAMPLE
The following example extracts all lines from std::cin and adds them to the std::vector<std::string> lines: #include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <bobcat/stringline> using namespace std; using namespace FBB; int main() { vector<string> lines; copy( istream_iterator<StringLine>(cin), istream_iterator<StringLine>(), back_inserter(lines) ); } FILES
bobcat/stringline - defines the class interface and operator>>. There are StringLine object files in the Bobcat library, so linking to Bobcat when using StringLine is not necessary. SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::StringLine(3bobcat)
All times are GMT -4. The time now is 07:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy