[solved]variable using ~ from a file

To put the things in short, I am trying to share some files/directory using quickserve and want to pass the file list thro' another file. before actual sharing I am trying to  test the actual file's existence but it fails with ~ / $HOME options.
File : ToExport.txt
contents:
~/Documents/File1.dot
~/Documents/File2.ods
/mnt/backup
the said file is passed as an argument to the bash script
Test function ...
for isvalid in $(cat "$1")
do
if [ -e "$isvalid" ]
then
echo "$isvalid passed for sharing"
else
echo "$isvalid does not exisits"
exit 4
fi
done
This fails. If I replace ~ with actual path it works.
(It may be easy to replace the entire list with the actual path by the simple search & replace funtion but the indention is to use the short form  ~ or $HOME instead of typing full path.
your inputs/correction are welcome
Last edited by kgas (2010-09-28 17:11:41)

This should work:
#!/bin/bash
#: Description : Checks file list to see files contained exist/are empty
fileList=/home/tom/fileList
## Go through each file in the fileList
while read aFile
do
## expand tildes (~)
eval aFile=$aFile
## check file exists
if [ -e $aFile ]
then
## check file is non-empty
if [ -s $aFile ]
then
printf "%s is a file.\n" $aFile
else
printf "%s is an empty file.\n" $aFile
fi
else ## file does not exist
printf "%s does not exist.\n" $aFile
fi
done < <( cat $fileList )
That code is a little more readable too. You where using the variable "isValid" for a file name.
Last edited by BaconPie (2010-09-21 10:29:51)

Similar Messages

  • Can we load data in variable screen from flat file?

    Hello all,
    One of my user once asked me she needs to run a report for some employees, i said you can just type that in employee varaible input box.
    She said I need to run the report and I need it for 120 employees, she has the employee numbers in excel sheet.
    What is the best way of doing this if any ?
    Thanks

    This can be done from a flat file, which has list of all values.
    If you are using Bex 3.5, then we have an icon in variable screen bottom right to upload values, where we can specify the path of the file.
    Naveen.a

  • Substitution variable using in rules file

    Hi,
    I have a requirement to load the data only for the current month. But, my source file is having data for all the months till current month.
    ex: I have to load data for MAY. But, source file is having data from JAN to MAY
    Its a monthly process and it should load the data only for the current month using substitution variable.
    Means next month I will be having JAN to JUN data. But, I should load only JUN data.
    Could any one help in building rules file for this requirement.
    Thanks
    Sri

    Is the data coming from SQL or a flat file?  And is JAN through MAY represented in multiple columns or multiple rows?
    As Evgeniy says if it's a SQL source, you can use a subvar in the SQL statement.  If it's a flat file (and your periods appear as multiple rows) you can use a subvar in a SELECT/REJECT criteria.
    Honestly though, if a feeding system is producing a flat file for you, I would try and arrange to have the flat file contain only the data that is actually required.  Parsing a file that is up to 12 times larger than necessary is inefficient.

  • Setting Oracle environment variable using batch (.bat) file in windows

    Hi,
    Oracle 9i db
    Windows OS
    I am in process to create the database (Considered that Oracle9i software is already installed) by running one batch file which consist of all the scripts for the database creation.
    But i also want to set the environment variables at MyComputer(right click)>properties>advance>environment, permenently by running the batch (.bat) file
    ORACLE_HOME
    ORACLE_BASE
    ORACLE_SID
    So, how can it be done ?
    With Regards

    Hi,
    *@echo off*
    set ORACLE_SID=iprsdb
    set ORACLE_BASE=C:\oracle
    set ORACLE_HOME=C:\oracle\ora92     
    call C:\install_bkp\test_env_var.bat
    echo Test Successfull.
    Above mentioned is the code written in the batch (.bat) file
    In that i have also called another .bat file which test the env. variable values which is as below:
    c:\>test_env.bat
    ===================
    Testing oracle sid
    ===================
    iprsdb
    =====================
    Testing oracle base
    ===================
    C:\oracle
    =====================
    Testing oracle home
    =====================
    C:\oracle\ora92
    Test Successfull.
    But when i checked at MyComputer(right click)>properties>advance>environment variables
    there, I saw none of the entries from the above, why so ?
    how to set env. variables permanently using the DOS commands. ?
    With Regards

  • Format of variable imported from FrameMaker file

    When I import my FrameMaker  files into RoboHelp, at least one of the variable formats changes. That is, a variable format containing a superscript character gets removed when imported into RoboHelp. Is there a way to fix this variable format in RoboHelp  or do I have to convert this variable format to text in FrameMaker before importing into RoboHelp.
    I am using the Technical Communicator Suite: FrameMaker 8.0 and RoboHelp 7
    Thanks

    I created a test project and imported one chapter.
    The results of the superscript were the same, that is, no superscript: C3 instead of C3. However, there is an exception to this behavior. If there is a cross reference, the cross reference retains the superscript.

  • AS3 send/import variables to/from php file

    Hi
    im new I would like to send some variables from ac3 to a
    php-file. the
    php-file have to copperate with this variable (send
    querystring to
    mysql-server).
    ac3 have to read then new variables and traced it on the
    screen.
    i found some examples on the net but i have not undersood
    any.
    can you please explane that to me????
    Sebastian

    Hi
    im new I would like to send some variables from ac3 to a
    php-file. the
    php-file have to copperate with this variable (send
    querystring to
    mysql-server).
    ac3 have to read then new variables and traced it on the
    screen.
    i found some examples on the net but i have not undersood
    any.
    can you please explane that to me????
    Sebastian

  • ODI variable refresh from a file

    In one of the the threads in the past I read some tips about how to refresh a variable from a flat file. I have some information in a flatfile which I need as a variable.
    Now I am reading the flat file into a SQL table and then refreshing it into the variable. I guess we can do this in one step. I am sure I read blog something about it. If anyone aware of the thread can you send the link.
    Thanks

    http://odiexperts.com/?p=243
    http://odiexperts.com/?p=243

  • Reintalled OS, but disk space is still being used from old files?

    I tried reinstalling the OS after my macbook would freeze when i tried to log in. I first tried to archive and install and then it said it couldn't complete that.I then put in the 2nd OS disc and it created a new user profile and my computer is working fine. The only thing is that a few alias are still being picked up from the old users and there is only 60 GB of space left on the hard drive. None of the information on the old user files is totally important so I can do without it, but I would like all my hard drive space back

    if you don't need the old user go to system preferences->accounts and delete the old user. also, check to see if you have a Previous System,s folder at the top level of the hard drive. delete that too and empty trash.

  • Firefox locks file if a hyperlink is used from that file

    If I used a hyperlink contain within a file, Firefox locks the file. Going to a different URL after does not release the file's lock.
    The only way I've found is to close Firefox. I am then able to delete the file containing the hyperlink.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Boot the computer in Windows Safe Mode with network support (press F8 on the boot screen) as a test to see if this helps.
    *http://www.bleepingcomputer.com/tutorials/how-to-start-windows-in-safe-mode/

  • [SOLVED]Recreating packages from installed files?

    Just a simple question. Suppose I do this:
    pacman -U pkg-foo.tar.xz
    # it installs successfully
    rm pkg-foo.tar.xz
    Is there a way to recreate the package file from the installed files and metadata on the system?
    Sorry if this is obvious, but I can't find anything on it.
    Last edited by nixscripter (2011-06-08 19:03:36)

    Just what I was looking for. Thanks!

  • Loading variable from a file in 7.0 Queries

    Hi All,
    When we run BW 3.x queries through RRMX, we get option to load the variables values via import from file means loading the variables values from a file. Do we have this option available in case of 7.0 queries also as 7.0 queries directly run on portal.
    I know via RSRT, i have that option available for 7.0 queries as well.
    Thanks in advance.
    Sumita.

    Hi,
       Please check out this link. They are requesting to use patch level 14 to the SAP front end.
    Re: Clipboard option in BI7
    Hope this helps for you.
    Thanks,
    Arun.

  • Loading Variable from a file in BI 7.0 queries

    Hi All,
    When we run BW 3.x queries through RRMX, we get option to load the variables values via import from file means loading the variables values from a file. Do we have this option available in case of 7.0 queries also as 7.0 queries directly run on portal.
    I know via RSRT, i have that option available for 7.0 queries as well.
    Thanks in advance.
    Sumita.

    Hi,
    In 7.0 it is not possible to load directly from a flat file when you run the query in the portal. However, I don't think it was an option in 3.x either. In het analyzer, both 3.x and 7.0 have that option, only the copy paste functionallity is gone in 7.0, you have to use a flatfile now. Also, in 7.0 portal you can add indivual values for a variable sperated by a ; sign. So you can use excel to create a ; seperated csv file and copy and paste from that.
    Kind regards,
    Alex

  • How to set ENV variable using user profile in solaris 10 while using ssh

    Hi,
    Please help me in setting the environment variable using user profile file while using ssh method of connection (Can I use the same ~/.profile file?)
    when i am logging in using the telnet, the environment variable is automattically set, but not when I am using SSH.
    Thanks in advance
    ushas symon

    Please list your .profile and a ls -la of your home directory.
    also list the result of env after your logged through telnet and ssh.
    There should be no difference - it depends mostly on your login shell which startup script it executes. ksh uses .profile, bash: bash_profile then .profile.

  • Create a cursor from a PL/SQL variable or an external file

    Dear friends,
    is there a way for me to make Oracle Forms read a cursor from a PL/SQL variable, or an external file? Let's suppose we have the code below:
    DECLARE
    cursor c_values is select * from my_table;
    r_values c_values%ROWTYPE;
    BEGIN
    for r_values in c_values loop
    do_something;
    end loop;
    END;
    In the situation described above, could I create "select * from my_table" from a PL/SQL variable (it could be something like p_cursor = 'select * from my_table'), or an external file - for example, make my form read the contents of c:\my_select.sql , where we see the "select * from my table" text?
    My question comes because I need to export data from select instructions that were dinamically created inside the form - that is, via PL/SQL -, and I don't want to rewrite it, but I'll have to do it if I have no choice. Your help will be greatly appreciated.
    Best regards,
    Franklin
    Edited by: franklinbrasil on 12/03/2009 11:33
    Edited by: franklinbrasil on 12/03/2009 11:35

    Dear friends,
    I am using DBMS_SQL package, which solved my problem. Please let me explain it better, if it's not clear.
    I have some PL/SQL blocks inside my form, which creates SQL queries dinamically, and a dinamically created SQL is stored into a VARCHAR2 variable. These SQL queries are exported for use in Oracle Graphics, but since OG is not being developed by Oracle anymore then I am trying to find a substitute for it.
    So I thought about creating an option for the final user: he/she can choose exporting data into Microsoft Excel, and user does what he/she wants, creating a customized graphic. Exporting into Excel works finely, with no problems at all - I could find a routine by searching on the web.
    My goal was to use the same queries created above to export data dinamically to Microsoft Excel, and I absolutely don't want to rewrite all these dinamically created queries - one which works dinamically, other with no flexibility inside my form. Worse than it, I have many other dinamically created queries, and I obviously don't want to rewrite them all - any maintenance in this form would be terrible, with each SQL instruction written twice.
    Since all dinamically created SQL instructions are stored inside a VARCHAR2 variable, I thought about reusing the same SQL, as explained above - and here we have your suggestions about using a ref cursor, execute immediate, and so on. And (answering Andreas) query structure is always based on the same table, but its structure changes a lot, depending on what the final user chooses in a drop-down list (it's a list of graphics options, where final user chooses one option, and form must mount SQL dinamically, based on user's choice).
    By using your explanations, I could find DBMS_SQL solution here: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg09dyn.htm#26799
    . Please notice that I had to change DBMS_SQL.native into 1 for it to work in my form. I'll mark all your answers as helpful because I can use them both for database and form purposes.
    If my message was not clear enough, please tell me and I'll try to make it more clear.
    Best regards,
    Franklin

  • Not able to extract performance data from .ETL file using xperf commands. getting error "Events were lost in this trace. Data may be unreliable ..."

    Not able to extract  performance data from .ETL file using xperf commands.
    Xperf Commands:
    xperf –i C:\TempFolder\Test.etl -o C:\TempFolder\BootData.csv  –a process
    Getting following error after executing above command:
    "33288636 Events were lost
    in this trace. 
    Data may be unreliable
    This is usually caused
    by insufficient disk bandwidth for ETW lo
    gging.
    Please try increasing the minimum
    and maximum number of buffers
    and/or
                    the buffer size. 
    Doubling these values would be a good first at
    tempt.
    Please note, though, that
    this action increases the amount of me
    mory
                    reserved
    for ETW buffers, increasing memory pressure on your sce
    nario.
    See "xperf -help start"
    for the associated command line options."
    I changed page size file but its does not work for me.
    Any one have idea, how to solve this problem and extract ETL file data.

    I want to mention one point here. I have total 4 machines out of these 3 machines above
    commands working properly. Only one machine has this problem.<o:p></o:p>
    Hi,
    I consider that you can try to use xperf to collect the trace etl file and see if it can be extracted on this computer:
    Refer to following articles:
    start
    http://msdn.microsoft.com/en-us/library/windows/hardware/hh162977.aspx
    Using Xperf to take a Trace (updated)
    http://blogs.msdn.com/b/pigscanfly/archive/2008/02/16/using-xperf-to-take-a-trace.aspx
    Kate Li
    TechNet Community Support

Maybe you are looking for

  • Can I set an mx control property globaly for all instances of the control.

    Is there a way of setting the value of a variable on a control for all instances of the control in the application?  For example, I have several instances of an mx:Label and I want to change the enabled property for all instances at once rather than

  • Problem with too small fonts

    Hi, after some update I've noticed my fonts are too slow on some websites, especially it applies for Google Mail: http://img518.imageshack.us/img518/1262/picture1ds9.png Google Reader is barely readable too, as well as some other pages. I've tried us

  • Find the table for fields QM related urgent

    hi all, Based on the inspection lot no. , I need to find out the fields 'short text for inspection characteristics' & 'original values'.   in which table i can find out. the transaction is QE03. If i press F1 it is referring to structure. Edited by:

  • Move scroll bar to currentrow

    I have two interactive reports. Both highlight the current row. One actually scrolls to the selected one so that it is always at the top of the report. One does not. I can't find the difference between the two reports.. What can make an IR scroll to

  • Cannot open up youtube to watch videos without firefox quitting on me

    Every time I open up youtube.com to watch a video, firefox will crash and quit on me. Additionally, if I want to watch a video from yahoo, the page will not load. The page doesn't say it is thinking (spinning wheel), but is just frozen and the only t