Sponsored Content
Top Forums Shell Programming and Scripting My code worked on a Mac, now it does not work in another computer Post 302862877 by Natalie on Friday 11th of October 2013 03:17:24 PM
Old 10-11-2013
My code worked on a Mac, now it does not work in another computer

I guess Mac has default bash. Then I copy my code to another comp and run it...And it gives me an error like "bad substitution"....

How I can change my code??? Never had before this kind of situation. Help please.

Code:
if [ -f "/Users/Natalie/lastserial" ]
then
  n=$(sort /Users/Natalie/lastserial | tail -1)

  fourthoct=${n:0:4}


 thirdoct=${n:4:2}
  thirdoct=${thirdoct#0}
  secondoct=${n:6:2}
  secondoct=${secondoct#0}
  firstoct=${n:8:2}
  firstoct=${firstoct#0}

  if [ $((++firstoct)) -eq 100 ]
  then
      firstoct=0
      if [ $((++secondoct)) -eq 32 ]
      then
          secondoct=0
          if [ $((++thirdoct)) -eq 13 ]
          then
              thirdoct=0
              ((++fourthoct))
          fi
      fi
  fi

  printf  "%04d%02d%02d%02d\n" $fourthoct $thirdoct $secondoct $firstoct > '/Users/Natalie/lastserial'
else
  echo ` date +%Y%m%d`"00" >'/Users/Natalie/lastserial'
fi

 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

why doesn't this script work on my home computer?

Now it could be as simple as at work I use tsch, and at home it is bash. Warning, first post and I am a complete newbie to unix. At work, I use a simple script for updating a window when I am watching to see how a render is doing... while 1 echo --------------------------- echo ls -lrth... (1 Reply)
Discussion started by: iStealMusic
1 Replies

2. What is on Your Mind?

If possible, would you consider buying OS X for a non Mac computer?

Title says it all. I am doing a little research for a blog I want to write up on my website about different OS platforms. One thing that I am trying to figure out, is that would it appeal to people to load OS X on their PC, and would they be willing to pay for it? If so, would you even... (17 Replies)
Discussion started by: tlarkin
17 Replies

3. What is on Your Mind?

Volunteer Work When Out of a Computer Job?

I need opinion from other ! I finished high school for computer technician few months ago and now I can not find a job because I do not have any experience with servers , I know basic staff about Linux and Unix and Windows better (used three 4 years) (this is way I registered here at... (3 Replies)
Discussion started by: solaris_user
3 Replies

4. UNIX for Dummies Questions & Answers

Code not worked,as expected

Hi All, OS :- HPUX.. I have a following code, which I wrote to meet date and time condition. The below code refuse to work for some reason, I still don't have any idea, why ? the below code, should exit out, if the day happens to be sat and time greater the 04:00 pm. I am bit surprised, that... (2 Replies)
Discussion started by: alok.behria
2 Replies

5. UNIX for Dummies Questions & Answers

Rebuilding computer tomorrow at work

I'm rebuilding my primary computer at work tomorrow. Currently, it has Windows 7. I would like to replace the main system with either Linux or Unix, although I would like to be able to run a fully operational Windows as a VM within that. Any recommendations on which Linux or Unix to go with? I'm... (6 Replies)
Discussion started by: Sean_
6 Replies
Net::Hotline::FileInfoItem(3pm) 			User Contributed Perl Documentation			   Net::Hotline::FileInfoItem(3pm)

NAME
Net::Hotline::FileInfoItem - File object used internally by Net::Hotline::Client SYNOPSIS
use Net::Hotline::FileInfoItem; $file = new Net::Hotline::FileInfoItem; $file->name("smile"); $file->comments("A happy file."); ... DESCRIPTION
Net::Hotline::FileInfoItem is a simple class for storing and retrieving file information, You should never have to create your own Net::Hotline::FileInfoItem objects when using Net::Hotline::Client. Getting and (to a lesser extent) setting attributes is all that should be necessary. CONSTRUCTION
new Creates a new Net::Hotline::FileInfoItem object with all attributes set to undef. METHODS
All the Net::Hotline::FileInfoItem methods are simple attribute get/set routines. If given an argument, they set an attribute. In all cases, they return the current value of the attribute. comment TEXT The file comments (as seen in the Mac OS Finder). ctime NUM The creation time of the file, given as a Mac OS native time value. Add the constant Net::Hotline::Constants::HTLC_MACOS_TO_UNIX_TIME to it to change it to seconds since the Unix epoch. creator TEXT The file creator, given as a four-letter Mac OS creator code ("TTXT", "SIT!", etc.) name TEXT The file name. icon The file icon given as a four-letter code. mtime NUM The modification time of the file, given as a Mac OS native time value. Add the constant Net::Hotline::Constants::HTLC_MACOS_TO_UNIX_TIME to it to change it to seconds since the Unix epoch. ctime NUM The creation time of the file, given as a Mac OS native time value. Add the constant Net::Hotline::Constants::HTLC_MACOS_TO_UNIX_TIME to it to change it to seconds since the Unix epoch. size NUM The size of the file in bytes. type TEXT The file type, given as a four-letter Mac OS type code ("TEXT", "PICT", etc.), Net::Hotline::Constants::HTLC_INFO_FOLDER_TYPE for folders, and Net::Hotline::Constants::HTLC_INFO_FALIAS_TYPE for folder aliases. AUTHOR
John C. Siracusa (siracusa@mindspring.com) COPYRIGHT
Copyright(c) 1999 by John Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2002-11-27 Net::Hotline::FileInfoItem(3pm)
All times are GMT -4. The time now is 10:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy